[jboss-user] [JBoss Seam] - org.hibernate.LazyInitializationException: Seam or Hibernate

c_eric_ray do-not-reply at jboss.com
Wed Jul 26 12:49:06 EDT 2006


Not sure where to post this so it's on the hibernate forum as well. I'm new to ejb, seam and hibernate so please excuse my ignorance.

I have a simple query that retrieves an entity from the database. Within that object I call a method to get a collection of different entitys.

Like so...

  | List<Object> l = entity.getCollection();
  | 

>From searching google and reading posts I understand that I have a session issue and could fix the problem by using and EAGER strategy. However, I cannot get the eager to work either. I get the same error regardless of what I do. 

I'm running the lastest version of JBoss AS and Seam.

Here's the actual code.

  | 
  |   @DataModel
  |   private Set<RemittanceItemEntity> remitItems;
  | 
  |     remitItems = packages.getSelectedClosedPackage().getRemittanceItems();    
  | 
  | -----------------
  | 
  | Here is the entity bean method with annotations
  | 
  | 	@OneToMany(mappedBy="remittancePackage")
  | 	public Set<RemittanceItemEntity> getRemittanceItems() {
  | 		return remittanceItems;
  | 	}
  | 
  | 
  | 

Here's the exception...although I'm sure you guys have seent this one before...

  | Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.vicor.DistributedCapture.ejb.PackageEntity.remittanceItems, no session or session was closed
  | 	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
  | 	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
  | 	at org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:97)
  | 	at org.hibernate.collection.PersistentSet.size(PersistentSet.java:114)
  | 	at java.util.ArrayList.<init>(ArrayList.java:133)
  | 	at org.jboss.seam.jsf.SetDataModel.setWrappedData(SetDataModel.java:96)
  | 	at org.jboss.seam.jsf.SetDataModel.<init>(SetDataModel.java:33)
  | 	at org.jboss.seam.databinding.DataModelBinder.wrap(DataModelBinder.java:48)
  | 	at org.jboss.seam.databinding.DataModelBinder.wrap(DataModelBinder.java:19)
  | 	at org.jboss.seam.Component.outjectDataModelList(Component.java:980)
  | 	at org.jboss.seam.Component.outjectDataModels(Component.java:937)
  | 	at org.jboss.seam.Component.outject(Component.java:857)
  | 	at org.jboss.seam.interceptors.BijectionInterceptor.bijectTargetComponent(BijectionInterceptor.java:41)
  | 	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.seam.util.Reflections.invoke(Reflections.java:13)
  | 	at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
  | 	at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
  | 	at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(ConversationInterceptor.java:82)
  | 	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.seam.util.Reflections.invoke(Reflections.java:13)
  | 	at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
  | 	at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
  | 	at org.jboss.seam.interceptors.BusinessProcessInterceptor.manageBusinessProcessContext(BusinessProcessInterceptor.java:60)
  | 	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.seam.util.Reflections.invoke(Reflections.java:13)
  | 	at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
  | 	at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
  | 	at org.jboss.seam.interceptors.RemoveInterceptor.removeIfNecessary(RemoveInterceptor.java:39)
  | 	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.seam.util.Reflections.invoke(Reflections.java:13)
  | 	at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
  | 	at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
  | 	at org.jboss.seam.ejb.SeamInterceptor.aroundInvokeInContexts(SeamInterceptor.java:73)
  | 	at org.jboss.seam.ejb.SeamInterceptor.aroundInvoke(SeamInterceptor.java:45)
  | 	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.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
  | 	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.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
  | 	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)
  | 	... 45 more
  | 

Thanks.
Eric Ray

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3961070#3961070

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3961070



More information about the jboss-user mailing list