I was trying to make this example work for me. Since my jbpm version is 6.3.0.Final, so this solution absolutely won't solve my problem.
My scenario is, firstly, I created a JPA & Dynamic Web Project by using Eclipse Mars1, and copied all the example files into my new project, then modified TaskProcessServlet.java, as shown below, because of the obsoleteness and deprecation of the Runtime
part in original servlet code. When I built my project and ran on independent Tomcat 7.0.64 other than server inside of Eclipse, and jsp showed up without any problem, but when I clicked create Process
which will fire the TaskProcessServlet, I got an error message:
Error:[PersistenceUnit: org.jbpm.persistence.jpa] Unable to build EntityManagerFactory
Would my postgresql-9.4.1207.jar(for Tomcat8) be a problem? I don't think so because I kept getting same error in Tomcat 8, so I downgrade my Tomcat from 8.0.30 to Tomcat 7.0.64.
I'm able to run jbpm-console from JBOSS both on my Tomcat 8 and 7. Does this jbpm-console interfere my project?
How to tackle this problem?
Any idea would be appreciated, thank you very much.
Software Environment:
Ubuntu 64-bit 14.04
Eclipse Mars1
jBPM 6.3.0.Final
PostgreSQL 9.3(postgresql-9.4.1207.jar)
Hibernate 4.2.21.Final
JPA 2.0
Tomcat 7.0.64
NO Spring
NO Maven
TaskProcessServlet.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
String action = request.getParameter("action");
if (action.equals("CreateProcess")) {
/*
UserTransaction ut = (UserTransaction) new InitialContext().lookup( "java:comp/UserTransaction" );
ut.begin();
*
* Get the local task service
*
KieSession ksession = JBPMUtil.getSingletonSession();
TaskService taskService = JBPMUtil.getTaskService();
ksession.startProcess("com.autopal.bpmn.sampleHTformvariables",params);
System.out.println(" after start");
//ksession.fireAllRules();
ut.commit();
*/
// create the entity manager factory
EntityManagerFactory emf = EntityManagerFactoryManager.get().getOrCreate("org.jbpm.persistence.jpa");
TransactionManager tm = TransactionManagerServices.getTransactionManager();
// setup the runtime environment
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get()
.newDefaultBuilder()
.addAsset(ResourceFactory.newClassPathResource("taskexample/SampleHumanTaskFormVariables.bpmn"), ResourceType.BPMN2)
.addEnvironmentEntry(EnvironmentName.TRANSACTION_MANAGER, tm)
.get();
// get the kie session
RuntimeManager manager = RuntimeManagerFactory.Factory.get().newPerRequestRuntimeManager(environment);
RuntimeEngine runtime = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
KieSession ksession = runtime.getKieSession();
// start the transaction
UserTransaction ut = InitialContext.doLookup("java:comp/UserTransaction");
ut.begin();
Map<String, Object> params = new HashMap<String, Object>();
params.put("priority", "High");
params.put("modelNumber", "123");
params.put("quantity", "66");
// perform multiple commands inside one transaction
ksession.startProcess("com.autopal.bpmn.sampleHTformvariables",params);
// commit the transaction
ut.commit();
request.setAttribute("message", "Process Created!");
RequestDispatcher rD = request.getRequestDispatcher("adminuser.jsp");
rD.forward(request, response);
}
...
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="org.jbpm.persistence.jpa" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:comp/env/jdbc/jbpm-ds</jta-data-source>
<mapping-file>META-INF/JBPMorm.xml</mapping-file>
<mapping-file>META-INF/Taskorm.xml</mapping-file>
<mapping-file>META-INF/Executor-orm.xml</mapping-file>
<mapping-file>META-INF/Servicesorm.xml</mapping-file>
<mapping-file>META-INF/TaskAuditorm.xml</mapping-file>
<class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.drools.persistence.info.SessionInfo</class>
<class>org.drools.persistence.info.WorkItemInfo</class>
<class>org.jbpm.process.audit.ProcessInstanceLog</class>
<class>org.jbpm.process.audit.NodeInstanceLog</class>
<class>org.jbpm.process.audit.VariableInstanceLog</class>
<class>org.jbpm.persistence.correlation.CorrelationKeyInfo</class>
<class>org.jbpm.persistence.correlation.CorrelationPropertyInfo</class>
<!-- manager -->
<class>org.jbpm.runtime.manager.impl.jpa.ContextMappingInfo</class>
<class>org.jbpm.services.task.impl.model.AttachmentImpl</class>
<class>org.jbpm.services.task.impl.model.ContentImpl</class>
<class>org.jbpm.services.task.impl.model.BooleanExpressionImpl</class>
<class>org.jbpm.services.task.impl.model.CommentImpl</class>
<class>org.jbpm.services.task.impl.model.DeadlineImpl</class>
<class>org.jbpm.services.task.impl.model.DelegationImpl</class>
<class>org.jbpm.services.task.impl.model.EscalationImpl</class>
<class>org.jbpm.services.task.impl.model.GroupImpl</class>
<class>org.jbpm.services.task.impl.model.I18NTextImpl</class>
<class>org.jbpm.services.task.impl.model.NotificationImpl</class>
<class>org.jbpm.services.task.impl.model.EmailNotificationImpl</class>
<class>org.jbpm.services.task.impl.model.EmailNotificationHeaderImpl</class>
<class>org.jbpm.services.task.impl.model.PeopleAssignmentsImpl</class>
<class>org.jbpm.services.task.impl.model.ReassignmentImpl</class>
<class>org.jbpm.services.task.impl.model.TaskImpl</class>
<class>org.jbpm.services.task.impl.model.TaskDataImpl</class>
<class>org.jbpm.services.task.impl.model.UserImpl</class>
<!--BAM for task service -->
<class>org.jbpm.services.task.audit.impl.model.BAMTaskSummaryImpl</class>
<properties>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL9Dialect"/>
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.jndi.class" value="bitronix.tm.jndi.BitronixInitialContextFactory"/>
<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.BitronixJtaPlatform"/>
</properties>
</persistence-unit>
Catalina.out
INFO: HHH000205: Loaded properties from resource hibernate.properties: {hibernate.connection.password=****, c3p0.numHelperThreads=10, c3p0.maxIdleTime=60, c3p0.testConnectionOnCheckout=true, c3p0.maxStatements=100, hibernate.show_sql=true, hibernate.default_catalog=mybox, hibernate.jdbc.batch_size=50, hibernate.bytecode.use_reflection_optimizer=false, hibernate.jdbc.fetch_size=100, c3p0.maxPoolSize=30, c3p0.initialPoolSize=3, hibernate.hbm2ddl.auto=create, hibernate.default_schema=public, hibernate.connection.release_mode=after_transaction, hibernate.connection.username=postgres, c3p0.idleConnectionTestPeriod=900, hibernate.connection.driver_class=org.postgresql.Driver, c3p0.minPoolSize=2, c3p0.preferredTestQuery=select now(), c3p0.acquireIncrement=3, hibernate.dialect=org.hibernate.dialect.PostgreSQL9Dialect, hibernate.connection.url=jdbc:postgresql://192.168.1.80:5432/mybox}
Feb 05, 2016 3:58:09 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Feb 05, 2016 3:58:10 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: META-INF/JBPMorm.xml
Feb 05, 2016 3:58:10 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: META-INF/Taskorm.xml
Feb 05, 2016 3:58:10 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: META-INF/Executor-orm.xml
Feb 05, 2016 3:58:10 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: META-INF/Servicesorm.xml
Feb 05, 2016 3:58:10 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: META-INF/TaskAuditorm.xml
Thanks Anton Giertli, Thank you for your attention.
I've solved this problem after modifying my server.xml and adding a hibernate.cfg.xml for JPA by referring to here.
But I still had consequential issues that I need to figure out.
Thank you any way.