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.  [ 15 posts ] 
Author Message
 Post subject: STRANGE CRASH ON FLUSHING
PostPosted: Mon Oct 04, 2004 12:12 am 
Newbie

Joined: Thu Apr 29, 2004 10:29 am
Posts: 13
Hibernate version:2.1.6

We got a strange problem during flushing a session. The problem is a NullPointerException throwed by Hibernate. We try to locate it and we have found that the original problem comes from the next method:

Code:
   public final class SessionImpl implements SessionImplementor {
   
   
   /**
    * ONLY near the end of the flush process, determine if the collection is dirty
    * by checking its entry
    */
   boolean collectionIsDirty(PersistentCollection coll) throws HibernateException {
      CollectionEntry entry = getCollectionEntry(coll);
      return entry.initialized && entry.dirty; //( entry.dirty || coll.hasQueuedAdds() );
   }


When obtains the "entry" reference it comes null and then the story is known... NullPointerExcception

Any idea??
Thanks...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 12:16 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Of course we can't help you unless you show the full stack trace, and your code.


http://www.hibernate.org/ForumMailingli ... AskForHelp


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 1:06 am 
Newbie

Joined: Thu Apr 29, 2004 10:29 am
Posts: 13
What stack trace?... there is nothing there.. just the nullpointerexception with a null message of course... nothing else..


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 1:17 am 
Newbie

Joined: Thu Apr 29, 2004 10:29 am
Posts: 13
About the code... i'm trying to get it together but it will take some time... but what it's doing is loading a object "A", putting another object "B" inside one of the collections of "A", saveOrUpdate() "A", and try to flush... then crash..


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 1:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
of course there is a stacktrace. you own code swallows it


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 12:10 pm 
Newbie

Joined: Thu Apr 29, 2004 10:29 am
Posts: 13
You're right, but the fact is that the hibernate method we post don't consider the possibility that the reference could come null using the variable assuming that it could never come null. What we are trying to understand is that if the problem is coused by a bug in the framework or by a result of wrong use of it...

The sequence of our application before the crash is like we told you on the precedent messages but we try to exlpain you again:

1-load an object (in this process we obtain the session and clear it)
2-add a new object to a collection of the first object loaded previously
3-save the second object (clearing again the session and invoking saveOrUpdate)
4-flush the session

During the flush process we got the NullPointerException...

About the stacktrace... my program wasn't eating it.. it was jboss.. anyway.. found it..

14:12:17,169 INFO [STDOUT] java.lang.NullPointerException
14:12:17,173 INFO [STDOUT] at net.sf.hibernate.impl.SessionImpl.collectionIsDirty(SessionImpl.java:2982)
14:12:17,175 INFO [STDOUT] at net.sf.hibernate.impl.DirtyCollectionSearchVisitor.processCollection(DirtyCollectionSearchVisitor.java:50)
14:12:17,178 INFO [STDOUT] at net.sf.hibernate.impl.AbstractVisitor.processValue(AbstractVisitor.java:69)
14:12:17,180 INFO [STDOUT] at net.sf.hibernate.impl.AbstractVisitor.processValues(AbstractVisitor.java:36)
14:12:17,181 INFO [STDOUT] at net.sf.hibernate.impl.SessionImpl.isUpdateNecessary(SessionImpl.java:2611)
14:12:17,183 INFO [STDOUT] at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2526)
14:12:17,186 INFO [STDOUT] at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2458)
14:12:17,188 INFO [STDOUT] at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2260)
14:12:17,189 INFO [STDOUT] at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2239)
14:12:17,191 INFO [STDOUT] at uy.edu.ort.persistence.HibernateMediator.save(HibernateMediator.java:87)
14:12:17,193 INFO [STDOUT] at uy.edu.ort.domain.manager.CompanyManager.save(CompanyManager.java:230)
14:12:17,195 INFO [STDOUT] at uy.edu.ort.domain.ejb.PropertyServicesBean.saveChoto(PropertyServicesBean.java:131)
14:12:17,197 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
14:12:17,199 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
14:12:17,201 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
14:12:17,203 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324)
14:12:17,206 INFO [STDOUT] at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
14:12:17,208 INFO [STDOUT] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
14:12:17,211 INFO [STDOUT] at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
14:12:17,214 INFO [STDOUT] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
14:12:17,217 INFO [STDOUT] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:315)
14:12:17,219 INFO [STDOUT] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
14:12:17,221 INFO [STDOUT] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
14:12:17,233 INFO [STDOUT] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
14:12:17,235 INFO [STDOUT] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
14:12:17,237 INFO [STDOUT] at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
14:12:17,240 INFO [STDOUT] at org.jboss.ejb.Container.invoke(Container.java:723)
14:12:17,241 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor154.invoke(Unknown Source)
14:12:17,244 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
14:12:17,246 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324)
14:12:17,247 INFO [STDOUT] at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
14:12:17,249 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
14:12:17,251 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
14:12:17,253 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
14:12:17,255 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:185)
14:12:17,257 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
14:12:17,260 INFO [STDOUT] at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:360)
14:12:17,261 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor153.invoke(Unknown Source)
14:12:17,264 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
14:12:17,266 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324)
14:12:17,268 INFO [STDOUT] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
14:12:17,269 INFO [STDOUT] at sun.rmi.transport.Transport$1.run(Transport.java:148)
14:12:17,272 INFO [STDOUT] at java.security.AccessController.doPrivileged(Native Method)
14:12:17,274 INFO [STDOUT] at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
14:12:17,276 INFO [STDOUT] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
14:12:17,278 INFO [STDOUT] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
14:12:17,280 INFO [STDOUT] at java.lang.Thread.run(Thread.java:534)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 2:58 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I think I did check that "bug" a long time ago, but it was a user misuse of Hibernate, and I've managed not to fix that potential NPE.

I can't remember exactly why was the cause however.

Are you reassociating the same collection from 1 object to another or something odd like that.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 4:10 pm 
Newbie

Joined: Thu Apr 29, 2004 10:29 am
Posts: 13
Mmmmmmmmmm.... nope.."A" it's just a simple object with a couple of Lists, and "B" is just an object with a String (of course ids and timestamps), and i'm just putting "B" inside a collection in "A" (if it's already inside i'm not doing anything). I'm not doing anything odd at all..

We did a little trick that is working, but isn't what we need, if we open the session, load the object, close the session, open other session do the rest and close the session.. it works... but isn't the best...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 4:15 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
are you working with a long session (storing it in httpSession for example)?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 5:28 pm 
Newbie

Joined: Thu Apr 29, 2004 10:29 am
Posts: 13
The session is really short.. just a few methods and i'm not using httpSession, i'm storing the session in a ThreadLocal and closing it at the end.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 8:39 pm 
Newbie

Joined: Thu Apr 29, 2004 10:29 am
Posts: 13
we keep trying different solutions for the problem and we removed the session.clear(), that fix the nullpointer but give us other problems.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 05, 2004 8:00 am 
Newbie

Joined: Thu Apr 29, 2004 10:29 am
Posts: 13
Hey guys...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 05, 2004 8:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
How about some code? That might help us diagnose the problem :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 06, 2004 6:07 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I agree Steve,
I'm stick with my idea of a wrong Hibernate usage. Show us the code to find the problem.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 08, 2006 8:35 am 
Newbie

Joined: Fri Feb 03, 2006 8:37 am
Posts: 2
We had the same exception when defining a "Set" in the java POJO, and map it it the mapping file with "list", which is obviously wrong. The exception is thrown if no data is changed, in a read-only operation.

Maybe this is a similar problem.

Anyway, the exception is rather obscure and hard to link directly to the collection type mismatch ..

_________________
wing tung Leung


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 15 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.