You can use the following construction:
When I run the above code , I got the following exception
Exception in thread "main" org.jbpm.api.JbpmException: no environment to get org.hibernate.Session at org.jbpm.api.env.Environment.getFromCurrent(Environment.java:196) at org.jbpm.api.env.Environment.getFromCurrent(Environment.java:189) at ae.emiratesid.bpm.demos.HistoryServiceTest.main(HistoryServiceTest.java:96)
I assumed you were calling this methdo from within a delegation from your process ... where do you want to use this method?
I want to use the method from a java client , the same place where I get a ProcessEngine instance
It is logical you can't find the current Hibernate Session, since there is none. A hibernate session is only open during a jbpm operation and is closed afterwards.
So I guess that basically what you want is access to the same SessionFactory as the one that is used by jBPM, which you can get through the processEngine in the same construct as the one I pasted above: