Thanks Scott,

I thought it was related to the service.  I figured it
was a singleton "so why am I using the constructor"
but didn't see getInstance.  Newbie didn't think to
look for a facade; doh!.  

I was not aware that every turbine service has a
facade (I was aware that Log is the facade for
LoggingService).

There is probably a documented list mapping the
facades to the service but I missed it - if not maybe
TR.props could have the facade in comments next to the
service registration.

Thanks again,
Terry

--- "Weaver, Scott" <[EMAIL PROTECTED]> wrote:
> This is not how you access services in Turbine.  To
> access the Security
> Service use the static methods provided by the
> facade class TurbineSecurity
> instead.
> 
> >             DBSecurityService dbum = new
> DBSecurityService();
> 
> Services are singleton classes that are initialized
> when Turbine starts and
> therefore you do not ever create new instances of
> them.  So just change
> references to dbnum to TurbinSecurity 
> 
> So, this
> dbum.accountExists(uName)
> 
> becomes:
> 
> TurbinSecurity .accountExists(uName)
> 
> hth,
> Scott
> 
> 
> > -----Original Message-----
> > From: Terry McBride [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, February 08, 2002 4:42 PM
> > To: [EMAIL PROTECTED]
> > Subject: User Registration - addUser 
> > 
> > 
> > Hi everyone,
> > 
> > I'm trying to write an action for registering
> users. 
> > I'm including the simple dev version I'm starting
> > with.  I get null pointer exceptions with
> > accountExists() and addUser().  Get somebody clue
> me
> > in to what I'm doing wrong?
> > 
> > Thanks in advance,
> > Terry
> > 
> > code and log follows......
> > 
> >     public void doPerform(RunData data, Context
> > context)
> >         throws Exception
> >     {
> >         Log.info("Registering a new user");
> >             TurbineUser user = new TurbineUser();
> >             DBSecurityService dbum = new
> DBSecurityService();
> > 
> >             // get the parameters passed in
> >             String fName =
> > data.getParameters().get("FirstName");
> >             String lName =
> data.getParameters().get("LastName");
> >             String uName =
> data.getParameters().get("UserName");
> >             String email =
> data.getParameters().get("Email");
> >             String password =
> > data.getParameters().get("Password");
> > 
> >             Log.debug("parameterParser: " +
> > data.getParameters());
> >             Log.debug("local vars: " + uName + password +
> fName
> > + lName + email);
> >             
> >             // set the properties
> >             user.setFirstName(fName);
> >             user.setLastName(lName);
> >             user.setUserName(uName);
> >             user.setEmail(email);
> > 
> >         Log.info("checking for user: " + uName);
> >             // check if username already exists
> >             try 
> >             {
> >                     if (dbum.accountExists(uName))
> >                     {
> >                             data.setMessage("A user with 
> > this user name
> > already exsits.  Please choosea nother name");
> >                             
> > data.setScreenTemplate("RegistrationForm.vm");
> >                             return;
> >                     }
> >             }
> >             catch (Exception e)
> >             {
> >                     Log.error("Error checking in username 
> > pre-exists",
> > e);
> >             }
> >             
> >             // store the user info
> >         Log.info("Attempting to create user: " +
> uName);
> >             dbum.addUser(user, password);
> > 
> >             // assign role
> >             Group group = dbum.getGlobalGroup();
> >             Role role = dbum.getRole("curriculum_editor");
> >             dbum.grant(user, group, role);
> > 
> >             // authenticate
> >             dbum.getAuthenticatedUser(uName, password);
> >             Log.debug("created account: " + user);
> >         
> >     }
> > 
> > 
> > 
> > 
> > 
> > 
> > [Fri Feb 08 13:28:22 PST 2002] -- INFO --
> Registering
> > a new user
> > 
> > [Fri Feb 08 13:28:22 PST 2002] -- DEBUG --
> > parameterParser: {action=RegisterUser}
> > {username=test}
> > {firstname=test}
> > {lastname=test}
> > {eventsubmit_doperform=Register}
> > {email=}
> > {template=Index.vm}
> > {password=test}
> > 
> > 
> > [Fri Feb 08 13:28:22 PST 2002] -- DEBUG -- local
> vars:
> > testtesttesttest
> > 
> > [Fri Feb 08 13:28:22 PST 2002] -- INFO -- checking
> for
> > user: test
> > 
> > [Fri Feb 08 13:28:22 PST 2002] -- ERROR -- Error
> > checking in username pre-exists
> > 
> >     Exception:  java.lang.NullPointerException
> > 
> >     Stack Trace follows:
> > 
> >     java.lang.NullPointerException
> > 
> >     at
> >
>
org.apache.turbine.services.security.BaseSecurityService.accou
> > ntExists(BaseSecurityService.java:292)
> > 
> >     at
> >
>
edu.stanford.mlkpp.curriculum.modules.actions.RegisterUser.doP
> > erform(RegisterUser.java:49)
> > 
> >     at java.lang.reflect.Method.invoke(Native Method)
> > .
> > .
> >     at
> >
>
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> > 
> >     at
> >
>
org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:371)
> > 
> >     at
> >
>
org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:424)
> > 
> >     at java.lang.Thread.run(Unknown Source)
> > 
> > 
> > 
> > [Fri Feb 08 13:28:22 PST 2002] -- INFO --
> Attempting
> > to create user: test
> > 
> > [Fri Feb 08 13:28:22 PST 2002] -- ERROR --
> > Turbine.handleException: null
> > 
> > [Fri Feb 08 13:28:22 PST 2002] -- ERROR -- 
> > 
> >     Exception: 
> > java.lang.reflect.InvocationTargetException
> > 
> >     Stack Trace follows:
> > 
> >     java.lang.reflect.InvocationTargetException:
> > java.lang.NullPointerException
> > 
> 
=== message truncated ===


__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to