JBoss Community

Re: jBPM 5.1 in a real world web application

created by Krishna Pitla in jBPM - View the full discussion

hi ashutosh,

 

try out this code

kbuilder.add(ResourceFactory.newClassPathResource(

"simplerule.drl"), ResourceType.DRL);



in your code where you try to start the process .



Sample code pasted below :





package

com.sample;

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

import

 

org.drools.KnowledgeBase;

import

 

org.drools.builder.KnowledgeBuilder;

import

 

org.drools.builder.KnowledgeBuilderFactory;

import

 

org.drools.builder.ResourceType;

import

 

org.drools.io.ResourceFactory;

import

 

org.drools.runtime.StatefulKnowledgeSession;

 

/**

* This is a sample file to launch a process.

*/

public

 

class

ProcessMain {

 

 

public static final void main(String[] args) throws

Exception {

 

// load up the knowledge base

KnowledgeBase kbase = readKnowledgeBase();

StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

 

// start a new process instance

ksession.startProcess(

"com.sample.bpmn.hello"

);

ksession.insert(

new

Account());

ksession.fireAllRules();

}

 

 

private static KnowledgeBase readKnowledgeBase() throws

Exception {

KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

kbuilder.add(ResourceFactory.newClassPathResource(

"simplerule.drl"), ResourceType.DRL

);

 

kbuilder.add(ResourceFactory.newClassPathResource(

"sample.bpmn"), ResourceType.BPMN2

);

 

return

kbuilder.newKnowledgeBase();

}

 

}

 



Hope this helps . Though i am still new to jbpm and drools. So if i have missed something then please pardon me.

Reply to this message by going to Community

Start a new discussion in jBPM at Community