[rules-users] How to get a package from Guvnor and start it

DO DavidIOwens at gmail.com
Thu Dec 6 11:42:09 EST 2012


I've posted this over in the JBPM forums, but now I think it's more of a
Guvnor question...

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
	Use this url to download package documentation PDF.

URL for package source:
http://localhost:8080/drools-guvnor/rest/packages/defaultPackage/source
	Use this URL to download the source, or in the 'runtime agent' to access
the rules in source form

URL for package binary:
 http://localhost:8080/drools-guvnor/rest/packages/defaultPackage/binary
	Use this url in the 'runtime agent' to fetch a pre compiled binary.

URL for running tests:
http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/defaultPackage/LATEST/SCENARIOS
	Use this url to run the scenarios remotely and collect results.

Change Set:
http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/defaultPackage/LATEST/ChangeSet.xml
	URL to change set for deployment agents.

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

Additionally it has this link Download binary package which is:
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("test", aconf);

        String url =
"http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/defaultPackage/LATEST/";

        UrlResource resource = (UrlResource)
ResourceFactory.newUrlResource(url);
        resource.setBasicAuthentication("enabled");
        resource.setUsername("guest");
        resource.setPassword("guest");        
		kagent.applyChangeSet(resource);

        return kagent.getKnowledgeBase();
    }
}

This code runs, authenticates, and then gives me back this error:
   ERROR drools.xml.ExtensibleXmlParser.fatalError  - (null: 1, 1): Content
is not allowed in prolog.

I figured out this was because I am trying to add the binary package as a
changeset, and it can't parse the binary file as a changeset... so I realize
my approach is kind of flawed... 

So how do I get the binary package from Guvnor and start the process?

Thank you!  



--
View this message in context: http://drools.46999.n3.nabble.com/How-to-get-a-package-from-Guvnor-and-start-it-tp4021113.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list