Hello experts,
we have a problem with hibernate inside JBPM, but we believe that is more a hibernate problem than a JBPM problem.
We have a class accessing the hibernate session from the jbpm context. Most of the time the method is executed correctly, but randomly
the method throws a "TransientObjectException: proxy was not associated with the session". See below the part from our class.
Code:
public ProcessInstance instanceForEntity(VehicleRelated entity, ProcessDefinition def) {
Session session = getJbpmContext().getSession();
if (!session.contains(entity)) {
if (log.isDebugEnabled()) {
log.debug(String.format("Session doesn't contains entity %s -> persisting entity.", entity));
}
session.persist(entity);
}
Query query = session.getNamedQuery(EntityToProcessInstance.BY_ENTITYNAME_ID);
String entityName = session.getEntityName(entity);
query.setString("entityName", entityName );
query.setLong("entityId", entity.getId() );
The interesting thing is that the session.contains(entity) returns true, so the entity is associated within the session.
The session.getEntityName(entity) throws the exception.
Is this issue related to Jira
HHH-3230?
Is there an workaround?
Thanks for you help
Marco
Hibernate version: 3.3.1.GA
Full stack trace of any exception that occurs:Code:
java.lang.reflect.UndeclaredThrowableException
at $Proxy52.getEntityName(Unknown Source)
at $Session_11faea3bd49.getEntityName($Session_11faea3bd49.java)
at $Session_11faea3bd4a.getEntityName($Session_11faea3bd4a.java)
at $Session_11faea3bd4b.getEntityName($Session_11faea3bd4b.java)
at core.processManagement.system.ProcessContextFactory$ProcessContextImpl.instanceForEntity(ProcessContextFactory.java:79)
at $ProcessContext_11faea3bd56.instanceForEntity($ProcessContext_11faea3bd56.java)
at $ProcessContext_11faea3bd57.instanceForEntity($ProcessContext_11faea3bd57.java)
at module.stateMachine.JbpmVehicleEventSink.getProcessInstanceForVehicle(JbpmVehicleEventSink.java:274)
at module.stateMachine.JbpmVehicleEventSink.invoice(JbpmVehicleEventSink.java:80)
at $VehicleEventSink_11faea3bd3f.invoice($VehicleEventSink_11faea3bd3f.java)
at $VehicleEventSink_11faea3bd3e.invoice($VehicleEventSink_11faea3bd3e.java)
at module.invoicing.service.invoicingService.InvoicingServiceImpl.invoiceInvoicableVehicles(InvoicingServiceImpl.java:132)
at module.invoicing.service.invoicingService.InvoicingServiceImpl.run(InvoicingServiceImpl.java:70)
at $Runnable_11faea3bd40.run($Runnable_11faea3bd40.java)
at $Runnable_11faea3bd37.run($Runnable_11faea3bd37.java)
at $Runnable_11faea3bd36.run($Runnable_11faea3bd36.java)
at ch.bmw.batch.BatchDriver.execute(BatchDriver.java:127)
at ch.bmw.batch.BatchDriver.runMain(BatchDriver.java:318)
at ch.bmw.batch.BatchDriver.main(BatchDriver.java:307)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.javaforge.honeycomb.hivemind.hibernate.HibernateSessionFactory$SessionProxy.invoke(HibernateSessionFactory.java:227)
... 19 more
Caused by: org.hibernate.TransientObjectException: proxy was not associated with the session
at org.hibernate.impl.SessionImpl.getEntityName(SessionImpl.java:1771)
... 24 more
Name and version of the database you are using:Oracle 10g
[/url][/code]