[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3119?page=c...
]
Nick de Graeve commented on HHH-3119:
-------------------------------------
Sorry that it took so long to respond but I had problems figuring out where exactly the
problem arose. Our datamodel is quite complex and the code that retrieves is accordingly
complex. Initially the simple test cases I created didn't fail. But eventually I found
the culprit: Session.clear()
POJOs: Level1->Level2->Level3
A Level1 object is retrieved, Session.clear() is called and that the object is printed.
The test runs ok if I use Hibernate version < 3.2.4. but a
"org.hibernate.LazyInitializationException: could not initialize proxy - no
Session" with any higher version.
The reason we use Session.clear()? We have a client/server application and we don't
want to send objects with all their dependent objects to the client. We have a utility
that achieves that by setting all non-primitive fields in a POJO to null. If we have a
dependent object we need to preserve, we copy the reference, use the cleaner on that and
set it back in the original object.
Doing this makes the POJOs dirty that's why we need the Session.clear(). We also tried
using setReadOnly(true) on the Query but that doesn't help with the dependent
objects.
This approach works perfect with our old Hibernate3.
LazyInitializationException from 3.2.4+ onward
----------------------------------------------
Key: HHH-3119
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3119
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.4, 3.2.4.sp1, 3.2.5, 3.2.6
Reporter: Nick de Graeve
Priority: Blocker
Attachments: hibernate.cfg.xml, HibernateTest.java, Level1.java, Level2.java,
Level3.java
We used to run JBoss 4.0.4.GA and we included Hibernate 3.2.0CR2 ourselves. Now we
migrated to JBoss 4.2.2.GA and in that one Hibernate 3.2.4.sp1 is included by default.
Unfortunately, we're getting LazyInitializationException when the object graph is
more than 2 levels deep.
E.g. RtTask --[OK]--> Priority --[FAIL]--> DictionaryEntry
We haven't changed anything to our beans or configuration files.
I did find out that v.3.2.4 is the first version that throws the exception.
Example stack trace:
2008-02-18 13:52:35,425 ERROR [org.hibernate.LazyInitializationException] could not
initialize proxy - no Session
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at
org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57)
at
org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
at
org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:166)
at
com.fpc.nokeos.core.common.beans.persistent.Priority_$$_javassist_13.getEntryName(Priority_$$_javassist_13.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
com.fpc.nokeos.core.server.dictionary.DictionaryContext.getField(DictionaryContext.java:319)
at
com.fpc.nokeos.core.server.dictionary.DictionaryContext.preparePojoAfterGetting(DictionaryContext.java:276)
at
com.fpc.nokeos.component.controlpanel.task.server.business.ControlPanelPluginTaskHelper.cleanRtTask(ControlPanelPluginTaskHelper.java:184)
at
com.fpc.nokeos.component.controlpanel.task.server.business.ControlPanelPluginTaskHelper.executeQueryToGetCPItem(ControlPanelPluginTaskHelper.java:575)
at
com.fpc.nokeos.component.controlpanel.task.server.business.ControlPanelPluginTaskHelper.getControlPanelItemsByFilter(ControlPanelPluginTaskHelper.java:525)
at
com.fpc.nokeos.component.controlpanel.task.server.ejb.ControlPanelPluginTaskBean.getControlPanelItemsByFilter(ControlPanelPluginTaskBean.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
at
org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
at
org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at
org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at
org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at
org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at
org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at
org.jboss.aspects.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:166)
at
org.jboss.ejb3.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:115)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at
org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
at
org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at
org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at
org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:304)
at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
at
org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:769)
at
org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:573)
at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:373)
at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166)
2008-02-18 13:52:35,534 ERROR [com.fpc.nokeos.core.server.dictionary.DictionaryContext]
Could not get field 'NAME'.
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
com.fpc.nokeos.core.server.dictionary.DictionaryContext.getField(DictionaryContext.java:319)
at
com.fpc.nokeos.core.server.dictionary.DictionaryContext.preparePojoAfterGetting(DictionaryContext.java:276)
at
com.fpc.nokeos.component.controlpanel.task.server.business.ControlPanelPluginTaskHelper.cleanRtTask(ControlPanelPluginTaskHelper.java:184)
at
com.fpc.nokeos.component.controlpanel.task.server.business.ControlPanelPluginTaskHelper.executeQueryToGetCPItem(ControlPanelPluginTaskHelper.java:575)
at
com.fpc.nokeos.component.controlpanel.task.server.business.ControlPanelPluginTaskHelper.getControlPanelItemsByFilter(ControlPanelPluginTaskHelper.java:525)
at
com.fpc.nokeos.component.controlpanel.task.server.ejb.ControlPanelPluginTaskBean.getControlPanelItemsByFilter(ControlPanelPluginTaskBean.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
at
org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
at
org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at
org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at
org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at
org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at
org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at
org.jboss.aspects.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:166)
at
org.jboss.ejb3.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:115)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at
org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
at
org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at
org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at
org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:304)
at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
at
org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:769)
at
org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:573)
at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:373)
at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166)
Caused by: org.hibernate.LazyInitializationException: could not initialize proxy - no
Session
at
org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57)
at
org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
at
org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:166)
at
com.fpc.nokeos.core.common.beans.persistent.Priority_$$_javassist_13.getEntryName(Priority_$$_javassist_13.java)
... 46 more
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira