Announcement Announcement Module

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions ( project, this forum has been decommissioned in favour of Spring Extensions one at:

Please see the Spring Extensions home page for a complete list of current projects in Java, .NET and ActionScript. You can also propose one if you want.

Costin Leau
SpringSource - Spring Training, Consulting, and Support - "From the Source"
See more
See less
[LazyInitializationException] could not initialize proxy - no Session Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • [LazyInitializationException] could not initialize proxy - no Session

    I have been trying to integrate Flex Spring and jbpm. Have simple setup as recommended in the spring modules documentation. I am using version 0.9

    Creating a new process works great.
    pi = this.jbpmTemplate.getProcessDefinition().createPro cessInstance();
    Token token = pi.getRootToken();
    System.out.println("After signal");
    long ldummy = this.jbpmTemplate.saveProcessInstance(pi);
    return pi;

    Another bean call to kick off tasks.Fails here
    ProcessInstance pi = jbpmTemplate.findProcessInstance(instanceId);
    return pi;

    Get this error
    [STDOUT] 21:32:58,598 ERROR [LazyInitializationException] could not initialize proxy - no Session
    org.hibernate.LazyInitializationException: could not initialize proxy - no Session
    at org.hibernate.proxy.AbstractLazyInitializer.initia lize(
    at org.hibernate.proxy.AbstractLazyInitializer.getImp lementation(
    at org.hibernate.proxy.pojo.javassist.JavassistLazyIn itializer.invoke( )
    at org.jbpm.graph.exe.ProcessInstance_$$_javassist_84 .getTaskMgmtInstance(ProcessInstance_$$_javassist_
    at bpmresources.dao.TestProcess.enterData(TestProcess .java:108)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De
    at java.lang.reflect.Method.invoke(
    at ter.invoke(
    at sage(
    at flex.messaging.MessageBroker.routeMessageToService (
    at flex.messaging.endpoints.AbstractEndpoint.serviceM essage(
    at flex.messaging.endpoints.amf.MessageBrokerFilter.i nvoke(
    at flex.messaging.endpoints.amf.LegacyFilter.invoke(L
    at flex.messaging.endpoints.amf.SessionFilter.invoke(
    at voke(
    at flex.messaging.endpoints.amf.SerializationFilter.i nvoke(
    at flex.messaging.endpoints.BaseHTTPEndpoint.service(
    at flex.messaging.MessageBrokerServlet.service(Messag
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    at ternalDoFilter(
    at Filter(
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(
    at ternalDoFilter(
    at Filter(
    at org.apache.catalina.core.StandardWrapperValve.invo ke(
    at org.apache.catalina.core.StandardContextValve.invo ke(
    at alve.invoke(
    at oke(
    at org.apache.catalina.core.StandardHostValve.invoke(
    at org.apache.catalina.valves.ErrorReportValve.invoke (
    at org.jboss.web.tomcat.service.jca.CachedConnectionV alve.invoke(
    at org.apache.catalina.valves.AccessLogValve.invoke(A
    at org.apache.catalina.core.StandardEngineValve.invok e(
    at org.apache.catalina.connector.CoyoteAdapter.servic e(
    at org.apache.coyote.http11.Http11Processor.process(H
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(

    Seems like there is no session. So i tried forcing a open session using this code
    return (ProcessInstance) jbpmTemplate.execute(new JbpmCallback(){
    public Object doInJbpm(JbpmContext context) throws JbpmException{
    context.setSession(jbpmTemplate.getHibernateTempla te().getSessionFactory().openSession());
    return context.getProcessInstance(instanceId);

    This works, but throws other warning. Is there a some explanation to this ?
    I am unable to find any help about this problem. Any adivse suggestion ?

  • #2

    Thanks for nothing.

    For anyone who would come across my situation. Some stuff what i found and how i fixed.

    I was not using a transaction manager to manage the transactions. So i got this error in the first place. If i had bundled all the actions into one transaction (function call), it worked great. If i split them into multiple function call within the same bean, i would get into this issue.

    I guess there are more folks trying to get this stuff too.

    Solution 1: I tried to use spring hibernate OpenSessionInViewInterceptor in the spring context file and in web.xml used a filter OpenSessionInViewFilter to keep the sessiion open . That did not work for me. As the servlet could not find the sessionFactory.

    Solution 2: I used a transaction manager injected with jbpmSession factory and added
    transactionAttributes bean
    transactionInterceptor bean
    autoProxy bean

    as below

    <bean id="transactionAttributes"
    class="org.springframework.transaction.interceptor .NameMatchTransactionAttributeSource">
    <property name="properties">
    <!-- <prop key="get*">PROPAGATION_SUPPORTS,readOnly</prop>-->
    <prop key="doSteps*">PROPAGATION_REQUIRED,-DAOException,timeout_600000</prop>

    <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor .TransactionInterceptor">
    <property name="transactionManager">
    <ref bean="transactionManager"/>
    <property name="transactionAttributeSource">
    <ref bean="transactionAttributes"/>

    <bean id="autoProxyCreator" class="org.springframework.aop.framework.autoproxy .BeanNameAutoProxyCreator">
    <property name="interceptorNames">
    <property name="beanNames">

    Now i named my bean to be called processXX. The autoProxy picks up any bean that ends with XX. I have doStepsDothis method that is picked up by transaction interceptor. This has been working for me.

    Too sad, that no one has put any kind of documentation on how to use the spring modules for jbpm.