11-18-2015 3:08 PM - edited 02-04-2024 4:51 AM
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?
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]
Datahub 5.7.0.2
affects MySQL and HSQLDB
all tables dropped, fresh install
Did you obtain the target items inside a transaction?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, I am facing the same issue with Hybris 5.7.0.3 Is there any update or workaround on this issue, on how to manage the JPA transactions in AdapterService?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Or instead of using TransactionTemplate, you could just define a separate bean that will fetch your TargetItems through the Publication Service and annotate that bean with @Transaction(propagation = Propagation.REQUIRED).
This way, you could just inject this bean into your adapterService class and correctly handle the publish method.
All documentation has been updated to include cross references to other documents and notations where appropriate.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
One needs to be aware of transactions:
This page should be linked in the Implementation guide as well! There is a document on how to implement an AdapterService, but no hint on transactions:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.