Find a jbpm session closed solution article

Source: Internet
Author: User
Tags jbpm

 

The Org. hibernate. lazyinitializationexception: failed to lazily initialize a collection of Role: Org. jbpm. PVM. internal. model. executionimpl. variables, no session or session was closed

CodeAs follows:

Executionservice = processengine. getexecutionservice ();
Processinstance executionservice. createprocessinstancequery (). processdefinitionid (processinstanceid). List ();
(Executionimpl) processinstance2). removevariable ("AA"); // an error is returned when the variable AA is deleted. Because the variable setting is a solution to delayed loading: If BS development mode is used, you can configure opensessioninviewfilter in Web. XML (Note: It must be written under struts configuration) <filter>
<Filter-Name> opensessioninviewfilter </filter-Name>
<Filter-class>
Org. springframework. Orm. hibernate3.support. opensessioninviewfilter
</Filter-class>
</Filter>
<Filter-mapping>
<Filter-Name> opensessioninviewfilter </filter-Name>
<URL-pattern>/* </url-pattern>
</Filter-mapping> Add in application. xml
<! -- @ Transactional flag is supported -->
<TX: annotation-driven transaction-Manager = "transactionmanager"/>

<! -- @ Aspectj flag is supported -->
<AOP: aspectj-autoproxy/>

<AOP: config proxy-target-class = "true">
<AOP: Advisor pointcut = "execution (* org. jbpm ..*.*(..))"
Advice-ref = "txadvice"/>
<AOP: Advisor pointcut = "execution (* COM. Jihong. jbpm. API. jbpmtemplate .*(..))"
Advice-ref = "txadvice"/>
</AOP: config>










Solution 2: Execute the processengine method to put a piece of code into a hibernate transaction and execute it to avoid delayed loading.
Public class removevarcommand implements command <void> {
Private string processinstanceid;
Private string varkey;
Public removevarcommand (string processinstanceid, string varkey ){
This. processinstanceid = processinstanceid;
This. varkey = varkey;
}
@ Override
Public void execute (environment) throws exception {
Executionservice = environment. Get (executionservice. Class );
Processinstance = executionservice. findprocessinstancebyid (processinstanceid );
(Executionimpl) processinstance). removevariable (varkey );
Return NULL;
}
}

Processengine.exe cute (New removevarcommand (processinstance. GETID (), "AA "));
 
Each Command is an independent transaction operation, and each excuete method is included by a hibernate firm. jbpm recommends using this method to expand related functions.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.