[jboss-user] [EJB 3.0] - failed to lazily initialize a collection of role
triathlon98
do-not-reply at jboss.com
Tue Jul 18 11:23:31 EDT 2006
I have the error below which happens during a call to e EJB3 SFSB. There is no explicit rollback happening in the code and the session is (obviously) managed by the container. I am using JBoss 4.0.4GA.
| 2006-07-17 06:02:05,374 ERROR [org.hibernate.LazyInitializationException] failed to lazily initialize a collection of role: org.ictrace.server.pm.DMWeightGroupTotalBean.batches, no session or session was closed
| org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: org.ictrace.server.pm.DMWeightGroupTotalBean.batches, 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.initialize(AbstractPersistentCollection.java:343) at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86) at org.hibernate.collection.PersistentBag.iterator(PersistentBag.java:246) at package.WeightMediatorBaseEx.addWGTBatch(WeightMediatorBaseEx.java:359) at ...
|
The code where the exception is invoced looks like this :
| private void addWGTBatch( DMWeightGroupTotalBean obj, String batchRef )
| throws UnidConstraintViolation
| {
| if ( obj == null || batchRef == null ) return;
| try
| {
| Collection<DMWeightGroupTotal_BatchesBean> batches = obj.getBatches();
| if ( batches == null )
| {
| batches = new ArrayList<DMWeightGroupTotal_BatchesBean>();
| obj.setBatches( batches );
| }
| // check if the object already exists
| for ( DMWeightGroupTotal_BatchesBean bb : batches ) // error is reported on this line
| {
| if ( batchRef.equals( bb.getBatches() ) ) return;
| }
| batches.add( new DMWeightGroupTotal_BatchesBean( batchRef ) );
| obj.modified();
| }
| catch ( Exception ex )
| {
| throw new UnidConstraintViolation( UCV_PROBLEM_WHEN_ADDING_BATCH_TO_THE_TOTAL_LINE, batchRef, ex );
| }
| }
|
Does anybody have any idea what is causing this error and how I can fix / work around it?
Thanks,
Joachim
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3958850#3958850
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3958850
More information about the jboss-user
mailing list