-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: NPE Thrown from Criteria.list( )
PostPosted: Fri May 06, 2005 7:06 pm 
Regular
Regular

Joined: Mon Jul 26, 2004 2:28 pm
Posts: 86
Location: Pensacola, Florida
I occasionally see the following stack trace in my log files:

Code:
mil.dfas.cm.bo.PersistenceException
   at mil.dfas.cm.bo.org.User.getTheme(User.java:338)
   at mil.dfas.cm.servlet.http.Theme.processRequest(Theme.java:70)
   at mil.dfas.cm.servlet.http.Theme.doGet(Theme.java:55)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
   at com.netscape.server.http.servlet.WrapperFilter.doFilter(WrapperFilter.java:74)
   at com.netscape.server.http.servlet.WFilterChain.doFilter(WFilterChain.java:118)
   at mil.dfas.cm.servlet.Secure.doFilter(Secure.java:81)
   at com.netscape.server.http.servlet.WFilterChain.doFilter(WFilterChain.java:118)
   at mil.dfas.cm.servlet.HibernateFilter.doFilter(HibernateFilter.java:112)
   at com.netscape.server.http.servlet.WebApplication.serviceServletFilters(WebApplication.java:1263)
   at com.netscape.server.http.servlet.WebApplication.service(WebApplication.java:1221)
   at com.netscape.server.http.servlet.NSServletRunner.ServiceWebApp(NSServletRunner.java:956)
   at com.netscape.server.http.servlet.NSServletSession.internalRedirect(Native Method)
   at com.netscape.server.http.servlet.NSRequestDispatcher.forward(NSRequestDispatcher.java:48)
   at mil.dfas.cm.servlet.http.main.SearchCases.processRequest(SearchCases.java:262)
   at mil.dfas.cm.servlet.http.main.SearchCases.doGet(SearchCases.java:60)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
   at com.netscape.server.http.servlet.WrapperFilter.doFilter(WrapperFilter.java:74)
   at com.netscape.server.http.servlet.WFilterChain.doFilter(WFilterChain.java:118)
   at mil.dfas.cm.servlet.HibernateFilter.doFilter(HibernateFilter.java:112)
   at com.netscape.server.http.servlet.WebApplication.serviceServletFilters(WebApplication.java:1263)
   at com.netscape.server.http.servlet.WebApplication.service(WebApplication.java:1221)
   at com.netscape.server.http.servlet.NSServletRunner.ServiceWebApp(NSServletRunner.java:956)
Caused by: java.lang.NullPointerException
   at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2105)
   at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:2001)
   at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1963)
   at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:69)
   at net.sf.hibernate.type.EntityType.resolveIdentifier(EntityType.java:208)
   at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2219)
   at net.sf.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:319)
   at net.sf.hibernate.loader.Loader.doQuery(Loader.java:309)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
   at net.sf.hibernate.loader.Loader.doList(Loader.java:1063)
   at net.sf.hibernate.loader.Loader.list(Loader.java:1054)
   at net.sf.hibernate.loader.CriteriaLoader.list(CriteriaLoader.java:118)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3660)
   at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:238)
   at mil.dfas.cm.bo.org.User.getTheme(User.java:315)


The gist of the getTheme function is that it looks at a user's organization and recurses up the organization tree until it finds an org with a theme. The criteria is:

Code:
session.createCriteria( Organization.class )
   .add( Expression.sql(
      "{alias}.org_id in " +
      "(  select org_id " +
      "   from org " +
      "   start with org_id=? " +
      "   connect by prior parent_org_id = org_id )",
      this.getOrganization( ).getOrganizationId( ),
      Hibernate.LONG ) )
   .list( );


I looked at SessionImpl.doLoad and the NPE is thrown on the last line of this block:

Code:
Object old = getEntity(key);
   if (old!=null) {  //if this object was already loaded
      EntityEntry oldEntry = getEntry(old);
      Status status = oldEntry.status; // NPE


oldEntry is null, which indicates that there is an old Entity, but no corresponding EntityEntry. What could cause that?

Some additional background: the user object is loaded on startup, detached from the Hibernate session, and stuck into the user session for the life of the user session (until the user logs out). The same user object could, potentially, be loaded in other parts of the application by other sessions, by virtue of its association to other objects (someObject.createdByUser, for example). Could that be related?

Any pointers/hints are greatly appreciated.

Thanks,

- Jesse


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 06, 2005 7:08 pm 
Regular
Regular

Joined: Mon Jul 26, 2004 2:28 pm
Posts: 86
Location: Pensacola, Florida
Forgot to mention: I'm using Hibernate 2.1.8, supplying my own connections from an external data source, running on Netscape Enterprise Server 6.1.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.