[jboss-user] [jBPM] - Re: How to get a package from Guvnor and start it

doboss do-not-reply at jboss.com
Thu Dec 6 13:04:41 EST 2012

doboss [https://community.jboss.org/people/doboss] created the discussion

"Re: How to get a package from Guvnor and start it"

To view the discussion, visit: https://community.jboss.org/message/780468#780468

I am so sad I couldn't figure that out myself!!!  :(( 

You are absolutely right Maciej! I just had to change the ResourceType to PKG and it works!!

For anyone else, here is the final working solution:

package org.jbpm.examples.quickstarts;
import java.util.HashMap;
import java.util.Map;
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.io.impl.UrlResource;
import org.drools.runtime.StatefulKnowledgeSession;
public class HelloRunner {
    public static final void main(String[] args) {
        try {
            // load up the knowledge base
            KnowledgeBase kbase = readKnowledgeBase();
            StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
            Map<String, Object> params = new HashMap<String, Object>();
            Person p = new Person("Maciej Swiderski");
            params.put("person", p);
            ksession.startProcess("com.sample.script", params);
        } catch (Throwable t) {
    private static KnowledgeBase readKnowledgeBase() throws Exception {
        String url = "http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/defaultPackage/LATEST";
        System.out.println("Going: " + url);
        UrlResource resource = (UrlResource) ResourceFactory.newUrlResource(url);
        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
        kbuilder.add(resource, ResourceType.PKG);
        return kbuilder.newKnowledgeBase();

Thank you Meciej! I owe you a beer or four!


Reply to this message by going to Community

Start a new discussion in jBPM at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20121206/0162b24d/attachment.html 

More information about the jboss-user mailing list