krishnendu kunti [
http://community.jboss.org/people/kkunti] created the discussion
"Re: Configuring JBPM 5 with other databases"
To view the discussion, visit:
http://community.jboss.org/message/578166#578166
--------------------------------------------------------------
Hi
Further on this thread... (running from eclipse) I am getting the following stacktrace..
java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException
....
Caused by: java.lang.reflect.InvocationTargetException
...
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: Unable to load
class: org.drools.persistence.processinstance.JPAProcessInstanceManagerFactory
...
by: java.lang.ClassNotFoundException: Unable to load class:
org.drools.persistence.processinstance.JPAProcessInstanceManagerFactory
on bit of an investigation looks like these classes are available in drools-xx--5.1.1 but
not there in drools-xx--5.2.0.. all the same on e cant' work with drools-xx5.1.1 as
some of the methods are missing which are required for creation of knowledge session.
Including my persistence.xml and java runner class... please have a look....
It will be a big help if someone can share some tips/code... to show it works..
-----------
package com.sw.test;
import java.util.HashMap;
import java.util.Map;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.compiler.BPMN2ProcessFactory;
import org.drools.compiler.ProcessBuilderFactory;
import org.drools.io.ResourceFactory;
import org.drools.logger.KnowledgeRuntimeLogger;
import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.marshalling.impl.ProcessMarshallerFactory;
import org.drools.persistence.jpa.JPAKnowledgeService;
import org.drools.runtime.Environment;
import org.drools.runtime.EnvironmentName;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.process.ProcessRuntimeFactory;
import org.jbpm.bpmn2.BPMN2ProcessProviderImpl;
import org.jbpm.marshalling.impl.ProcessMarshallerFactoryServiceImpl;
import org.jbpm.process.builder.ProcessBuilderFactoryServiceImpl;
import org.jbpm.process.instance.ProcessRuntimeFactoryServiceImpl;
import org.jbpm.process.workitem.wsht.WSHumanTaskHandler;
public class MyProcesstest {
/**
* @param args
*/
public static void main(String[] args) {
try {
KnowledgeBase kbase = readKnowledgeBase();
EntityManagerFactory emf =
Persistence.createEntityManagerFactory( "org.jbpm.persistence.my"
);
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );
// create a new knowledge session that uses JPA to store the runtime state
StatefulKnowledgeSession ksession =
JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );
int sessionId = ksession.getId();
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, "test", 1000);
ksession.getWorkItemManager().registerWorkItemHandler("Human
Task", new WSHumanTaskHandler());
// start a new process instance
Map<String, Object> params = new HashMap<String,
Object>();
params.put("employee", "krisv");
ksession.startProcess("com.sample.evaluation", params);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
ProcessBuilderFactory.setProcessBuilderFactoryService(new
ProcessBuilderFactoryServiceImpl());
ProcessMarshallerFactory.setProcessMarshallerFactoryService(new
ProcessMarshallerFactoryServiceImpl());
ProcessRuntimeFactory.setProcessRuntimeFactoryService(new
ProcessRuntimeFactoryServiceImpl());
BPMN2ProcessFactory.setBPMN2ProcessProvider(new BPMN2ProcessProviderImpl());
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("Evaluation.bpmn"),
ResourceType.BPMN2);
return kbuilder.newKnowledgeBase();
}
}
------------------------
<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
<persistence version="1.0"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
xmlns:orm="
http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance
http://www.w3.org/2001/XMLSchema-instance"
xmlns="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence">
<persistence-unit name="org.jbpm.persistence.my">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>org.drools.persistence.session.SessionInfo</class>
<class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.jbpm.persistence.processinstance.ProcessInstanceEventInfo</class>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.connection.driver_class"
value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.url"
value="jdbc:mysql://localhost:3306/jbpmdb" />
<property name="hibernate.connection.username"
value="root"/>
<property name="hibernate.connection.password"
value="admin"/>
<property name="hibernate.connection.autocommit"
value="false" />
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.hbm2ddl.auto" value="create" />
<property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
</persistence>
-----------------------------
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/578166#578166]
Start a new discussion in jBPM at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]