You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by John McNally <jm...@collab.net> on 2001/12/07 21:17:14 UTC

[Fwd: Unable to restart Scarab!!]

A problem calling Torque.init() without a valid configuration object
having been set and related to the abstract/static nature of the class. 
Not sure how to solve, so passing it on for others to ponder.

john mcnally

John McNally wrote:
> 
> That is a damn good analysis of the problem.  I would expect this
> problem might occur with class reloading turned on as well, but I have
> never experienced the problem.  I wonder what is different about the two
> cases.  I will submit this analysis to turbine/torque list, if you do
> not mind.
> 
> john mcnally
> 
> Maarten Coene wrote:
> >
> > I agree with you that these patches were not the best solution: they only
> > solve the symptoms, not the real problem causing these symptoms...
> > But: it seems that I'm the only one getting this problem. Maybe I do
> > something wrong???? I've tried it on 3 different machines and all gave me
> > this same problem.
> >
> > Here is what I think is happening:
> >
> > Some object (I don't know which) in Tomcats session has a reference to a
> > BaseTurbineUser object. If I shutdown tomcat, this object is serialized and
> > saved by tomcat. If I restart tomcat, it will try to restore its session by
> > reloading this object. But: the BaseTurbineUser class has this static field:
> >
> >          private static final TurbineUserPeer peer = new TurbineUserPeer();
> >
> > This class again has a static reference to BaseTurbineUserPeer and this
> > class has a static field pointing to BasePeer:
> >
> >          protected static final TurbineUserMapBuilder mapBuilder =
> >                  (TurbineUserMapBuilder)BasePeer.getMapBuilder("org.apache.fulcrum.security.impl.db.entity.map.TurbineUserMapBuilder");
> >
> > The getMapBuilder method will call the doBuild() method on the class
> > TurbineUserMapBuilder. This method will call
> > Torque.getDatabaseMap("scarab"). The getDatabaseMap method of the Torque
> > class contains this code:
> >
> >          if (dbMaps == null)
> >          {
> >              try
> >              {
> >                  Torque.init();
> >              }
> >              catch (Exception e)
> >              {
> >                  e.printStackTrace();
> >              }
> >          }
> >
> >          synchronized (dbMaps)
> >          {
> >              DatabaseMap map = (DatabaseMap) dbMaps.get(name);
> >              if (map == null)
> >              {
> >                  // Still not there.  Create and add.
> >                  map = initDatabaseMap(name);
> >              }
> >              return map;
> >          }
> >
> > since I think this is the first time the Torque class is called, dbMaps
> > will be null and the init() method will be called. Also because this is the
> > first call to the Torque class, configurations will be null and the init()
> > method will throw an Exception catch by the try-catch block (this error
> > message is printed by tomcat on the console window). But: the story
> > continues and here the problems start. After the init() call, the dbMaps
> > are still null. This means that the first line in the synchronized block
> > will throw a NullPointerException... This is catched again by the
> > BasePeer.getMapBuilder method and null is returned. This means that the
> > BaseTurbineUserPeer has a final static field mapBuilder which is equal to
> > null (see above)
> >
> > *phew*... still with me??
> >
> > Next, if I try to login, the method doSelectVillageRecords on the
> > BaseTurbineUserPeer class will be called (remember: the mapBuilder field of
> > this class is null). This method will do the following:
> >
> >          Criteria selectCriteria = new
> > Criteria(mapBuilder.getDatabaseMap().getName(), 2);
> >
> > And here the login fails because this will throw a NullPointerException...
> > Here is a part of the "login-exception":
> > 2001-12-07 09:56:40,819 [HttpProcessor[8080][4]] ERROR default - Login:
> > java.lang.NullPointerException
> >          at
> > org.apache.fulcrum.security.impl.db.entity.BaseTurbineUserPeer.doSelectVillageRecords(BaseTurbineUserPeer.java:266)
> >          at
> > org.apache.fulcrum.security.impl.db.entity.BaseTurbineUserPeer.doSelectVillageRecords(BaseTurbineUserPeer.java:238)
> >          at
> > org.apache.fulcrum.security.impl.db.entity.BaseTurbineUserPeer.doSelect(BaseTurbineUserPeer.java:216)
> >          at
> > org.apache.fulcrum.security.impl.db.DBUserManager.retrieve(DBUserManager.java:166)
> >          at
> > org.apache.fulcrum.security.impl.db.DBUserManager.retrieve(DBUserManager.java:250)
> >          at
> > org.apache.fulcrum.security.BaseSecurityService.getAuthenticatedUser(BaseSecurityService.java:312)
> >          at
> > org.apache.fulcrum.security.TurbineSecurity.getAuthenticatedUser(TurbineSecurity.java:196)
> >          at org.tigris.scarab.actions.Login.checkUser(Login.java:114)
> >          at org.tigris.scarab.actions.Login.doLogin(Login.java:88)
> >
> > What I did was to make sure the mapBuilder field was not null. But I was
> > suprised myself that it worked, so don't ask me why... I was so happy that
> > I could finally use scarab again that I didn't have the courage to search
> > any further.
> > Maybe someone knows a better way to resolve this problem?
> >
> > Maarten
> >
> > At 17:31 6/12/2001 -0800, you wrote:
> > >Forget my thinking it might be a multithread problem.  I do not
> > >understand how this patch helps you prevent the exception.  Is it still
> > >occuring?
> > >
> > >john mcnally
> >
> > --
> > Maarten Coene
> > Katholieke Universiteit Leuven
> > Dept. Computerwetenschappen             Tel: ++32 (0)16/32 78 25
> > Celestijnenlaan 200A
> > B-3001 Heverlee
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@scarab.tigris.org
> > For additional commands, e-mail: dev-help@scarab.tigris.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@scarab.tigris.org
> For additional commands, e-mail: dev-help@scarab.tigris.org

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>