[opencms-dev] How to initialize the CmsDriverManager?

Borja Marcos Suarez borja.suarez at fundacionctic.org
Fri May 20 08:32:31 CEST 2005


Hi all,

 

I'm developing a module for opencms (last version from cvs). In this
module I need to manage users (add, modify and remove) and I need also
to access to mysql database.

 

As far as I'm concerned the way to do it is with CmsUserDriver and
DriverManager classes as follows: 

 

userDriver.createUser(dbContext,name,password,description,firstName,last
Name,email,0,I_CmsConstants.C_FLAG_ENABLED,new
HashMap(),address,userType);

 

The problem is that I get NullPointer exception in existUser method and
I'm almost sure that is due the initialization of CmsDriverManager
class.

 

This is the code I used:

 

                        CmsJspActionElement cmsjsp = new
CmsJspActionElement(pageContext,request, response);


                        CmsRequestContext requestContext=
cmsjsp.getRequestContext();

                        CmsDbContext dbContext= new CmsDbContext
(requestContext);

                        

                        CmsUserDriver userDriver= new CmsUserDriver ();

                        String configPath =
pageContext.getServletContext().getRealPath("/") + "WEB-INF" +
File.separator + "config" + File.separator;

                        CmsConfigurationManager configurationManager =
new CmsConfigurationManager(configPath);

                        

                        LinkedList l= new LinkedList ();

                        l.add("org.opencms.db.mysql.CmsUserDriver");   

                        

                        CmsSecurityManager securityManager= null;

                        try {

                                   securityManager =
CmsSecurityManager.newInstance(configurationManager,null);

                        } 

                        catch (CmsException e1) {

                                   throw new BusinessException ("No
consigo inicializar el security manager: " + e1.getMessage());

                        }

                        CmsDriverManager driverManager;

                        

                        try {

                                   driverManager=
CmsDriverManager.newInstance(configurationManager,securityManager,null);

                        } catch (CmsException e2) {

                                   throw new BusinessException ("No
consigo inicializar el drivermanager: " + e2.getMessage());

                        }

                        userDriver.init
(dbContext,configurationManager,l,driverManager);

 

What is wrong in this code??

 

Please help, thanks in advance,

 

Borja

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20050520/df22eace/attachment.htm>


More information about the opencms-dev mailing list