Skip to Content
0
Nov 18, 2015 at 03:08 PM

Datahub: LazyInitializationException when obtaining target items

346 Views

Problem

I'm getting the following Exception:

 org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.hybris.datahub.domain.jpa.entities.TargetSystemEntity.targetItemMetadataEntities, could not initialize proxy - no Session

The Exception occurs when trying to obtain all target items in an AdapterService:

 publicationActionService.findTargetItemsByPublication(publicationId, targetItemType, pageable);

I get the same Exception with the following deprecated code as well:

 targetSystemPublication.getTargetItems();

Any ideas where to start hunting this down?

Stack Trace

 org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.hybris.datahub.domain.jpa.entities.TargetSystemEntity.targetItemMetadataEntities, could not initialize proxy - no Session
     at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:575) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
     at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:214) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
     at org.hibernate.collection.internal.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:155) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
     at org.hibernate.collection.internal.PersistentSet.size(PersistentSet.java:160) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
     at com.hybris.datahub.service.impl.DefaultPublicationActionService.getSubTargetSystemPublication(DefaultPublicationActionService.java:287) ~[datahub-service-5.7.0.2-RC1.jar:5.7.0.2-RC1]
     at com.hybris.datahub.service.impl.DefaultPublicationActionService.getTargetSystemPublication(DefaultPublicationActionService.java:308) ~[datahub-service-5.7.0.2-RC1.jar:5.7.0.2-RC1]
     at com.hybris.datahub.service.impl.DefaultPublicationActionService.findTargetItemsByPublication(DefaultPublicationActionService.java:336) ~[datahub-service-5.7.0.2-RC1.jar:5.7.0.2-RC1]
     at sun.reflect.GeneratedMethodAccessor2445.invoke(Unknown Source) ~[na:na]
     at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_66]
     at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) ~[spring-aop-4.1.5.RELEASE.jar:4.1.5.RELEASE]
     at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:201) ~[spring-aop-4.1.5.RELEASE.jar:4.1.5.RELEASE]
     at com.sun.proxy.$Proxy134.findTargetItemsByPublication(Unknown Source) ~[na:na]

Environment

  • Datahub 5.7.0.2

  • affects MySQL and HSQLDB

    all tables dropped, fresh install