Announcement Announcement Module
Collapse

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions (http://www.springsource.org/extensions) project, this forum has been decommissioned in favour of Spring Extensions one at:
http://forum.springsource.org/forumdisplay.php?f=44

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.

Cheers,
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
See more
See less
[LazyInitializationException] could not initialize proxy - no Session Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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();
    token.signal();
    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(AbstractLazyInitializer.java:57)
    at org.hibernate.proxy.AbstractLazyInitializer.getImp lementation(AbstractLazyInitializer.java:111)
    at org.hibernate.proxy.pojo.javassist.JavassistLazyIn itializer.invoke(JavassistLazyInitializer.java:166 )
    at org.jbpm.graph.exe.ProcessInstance_$$_javassist_84 .getTaskMgmtInstance(ProcessInstance_$$_javassist_ 84.java)
    at bpmresources.dao.TestProcess.enterData(TestProcess .java:108)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at flex.messaging.services.remoting.adapters.JavaAdap ter.invoke(JavaAdapter.java:421)
    at flex.messaging.services.RemotingService.serviceMes sage(RemotingService.java:183)
    at flex.messaging.MessageBroker.routeMessageToService (MessageBroker.java:1503)
    at flex.messaging.endpoints.AbstractEndpoint.serviceM essage(AbstractEndpoint.java:884)
    at flex.messaging.endpoints.amf.MessageBrokerFilter.i nvoke(MessageBrokerFilter.java:121)
    at flex.messaging.endpoints.amf.LegacyFilter.invoke(L egacyFilter.java:158)
    at flex.messaging.endpoints.amf.SessionFilter.invoke( SessionFilter.java:44)
    at flex.messaging.endpoints.amf.BatchProcessFilter.in voke(BatchProcessFilter.java:67)
    at flex.messaging.endpoints.amf.SerializationFilter.i nvoke(SerializationFilter.java:146)
    at flex.messaging.endpoints.BaseHTTPEndpoint.service( BaseHTTPEndpoint.java:278)
    at flex.messaging.MessageBrokerServlet.service(Messag eBrokerServlet.java:322)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:230)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:173)
    at org.jboss.web.tomcat.security.SecurityAssociationV alve.invoke(SecurityAssociationValve.java:182)
    at org.jboss.web.tomcat.security.JaccContextValve.inv oke(JaccContextValve.java:84)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:104)
    at org.jboss.web.tomcat.service.jca.CachedConnectionV alve.invoke(CachedConnectionValve.java:157)
    at org.apache.catalina.valves.AccessLogValve.invoke(A ccessLogValve.java:543)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:241)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)


    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
    Solved

    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">
    <props>
    <!-- <prop key="get*">PROPAGATION_SUPPORTS,readOnly</prop>-->
    <prop key="doSteps*">PROPAGATION_REQUIRED,-DAOException,timeout_600000</prop>
    </props>
    </property>
    </bean>

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

    <bean id="autoProxyCreator" class="org.springframework.aop.framework.autoproxy .BeanNameAutoProxyCreator">
    <property name="interceptorNames">
    <value>transactionInterceptor</value>
    </property>
    <property name="beanNames">
    <value>*XX</value>
    </property>
    </bean>


    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.

    Comment

    Working...
    X