I added that but it was asking to define getkbase().So I manupulated the code.Kindly have a look and advice me that how can I correct it.
Also tell me how can I test this concept.Where to find out the database in which the details are stored.
For your reference the code is as below:
package sample;
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.io.ResourceFactory;
import org.drools.persistence.jpa.JPAKnowledgeService;
import org.drools.runtime.StatefulKnowledgeSession;
import org.jbpm.process.audit.JPAWorkingMemoryDbLogger;
import org.jbpm.test.JBPMHelper;
public class historyLog {
/**
* @param args
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
//JBPMHelper.startH2Server();
//JBPMHelper.setupDataSource();
//EntityManagerFactory emf =
// Persistence.createEntityManagerFactory( "org.jbpm.persistence.jpa" );
org.drools.runtime.Environment env = KnowledgeBaseFactory.newEnvironment();
KnowledgeBase kbase = readKnowledgeBase();
//StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
//JPAWorkingMemoryDbLogger logger = new JPAWorkingMemoryDbLogger(ksession);
StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);
JPAWorkingMemoryDbLogger jbpmLogger = new JPAWorkingMemoryDbLogger(ksession);
ksession.startProcess("sample.bpmn.hh");
jbpmLogger.dispose();
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("demo2.bpmn"), ResourceType.BPMN2);
return kbuilder.newKnowledgeBase();
}
}