JBoss Community

How to get a package from Guvnor and start it

created by doboss in jBPM - View the full discussion

Can anyone tell me how to get a process/package from Guvnor and run it from a java app using the demo setup?

 

I have installed jbpm via the JBPM 5.4 full installer. I have taken the ScriptTask.bpmn from jbpm-examples and successfully put it in the Guvnor. I have added a Model Pojo and was able to build the package inside the default package. I have even created a snapshot.

 

Guvnor lists these URLS:

URL for package documentation:

http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/defaultPackage/LATEST/documentation.pdf

http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/clear.cache.gif

URL for package source:

http://localhost:8080/drools-guvnor/rest/packages/defaultPackage/source

http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/clear.cache.gif

URL for package binary:

http://localhost:8080/drools-guvnor/rest/packages/defaultPackage/binary

http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/clear.cache.gif

URL for running tests:

http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/defaultPackage/LATEST/SCENARIOS

http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/clear.cache.gif

Change Set:

http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/defaultPackage/LATEST/ChangeSet.xml

http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/clear.cache.gif

POJO Model:

http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/defaultPackage/LATEST/MODEL

http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/clear.cache.gif

 

Additionally it has this link Download binary package

Which is to: http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/defaultPackage/LATEST

 

Now I have my main java app:

 

  package org.jbpm.examples.quickstarts;import java.util.HashMap;import java.util.Map;import org.drools.KnowledgeBase;import org.drools.agent.KnowledgeAgent;import org.drools.agent.KnowledgeAgentConfiguration;import org.drools.agent.KnowledgeAgentFactory;import org.drools.io.Resource;import org.drools.io.ResourceFactory;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("Krisv");            params.put("person", p);            ksession.startProcess("com.sample.script", params);        } catch (Throwable t) {            t.printStackTrace();        }    }    private static KnowledgeBase readKnowledgeBase() throws Exception {        KnowledgeAgentConfiguration aconf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();        KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("testKAgent", aconf);        String fileName = "http://localhost:8080/drools-guvnor/rest/packages/defaultPackage/binary";        Resource newUrlResource = ResourceFactory.newUrlResource(fileName);        kagent.applyChangeSet(newUrlResource);        return kagent.getKnowledgeBase();    }}

 

 

I have also tried the URL: http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/defaultPackage/LATEST

 

But I keep getting this error:

 

java.lang.RuntimeException: Unable to parse ChangeSet
    at org.drools.agent.impl.KnowledgeAgentImpl.getChangeSet(KnowledgeAgentImpl.java:454)
    at org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:184)
    at org.jbpm.examples.quickstarts.HelloRunner.readKnowledgeBase(HelloRunner.java:52)
    at org.jbpm.examples.quickstarts.HelloRunner.main(HelloRunner.java:30)
Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/defaultPackage/LATEST
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1615)
    at org.drools.io.impl.UrlResource.grabStream(UrlResource.java:210)
    at org.drools.io.impl.UrlResource.getInputStream(UrlResource.java:146)
    at org.drools.io.impl.UrlResource.getReader(UrlResource.java:214)
    at org.drools.agent.impl.KnowledgeAgentImpl.getChangeSet(KnowledgeAgentImpl.java:451)
    ... 3 more
java.lang.RuntimeException: Unable to parse ChangeSet
    at org.drools.agent.impl.KnowledgeAgentImpl.getChangeSet(KnowledgeAgentImpl.java:465)
    at org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:184)
    at org.jbpm.examples.quickstarts.HelloRunner.readKnowledgeBase(HelloRunner.java:52)
    at org.jbpm.examples.quickstarts.HelloRunner.main(HelloRunner.java:30)

 

 

I've read various posts about removing authentication and/or putting in the username/password.

 

I am running the demo stuff, so my understanding is there is no authentication.

 

So how do I specify a username/password?

 

I've read something about putting the password in a changeset.xml, but haven't figured out how to do that either...

 

Thanks!

Reply to this message by going to Community

Start a new discussion in jBPM at Community