Discussion:
[jboss-user] [jBPM] - How can I take process definitions from Guvnor with jBPM5 API?
liliana.iovanovici
2012-02-13 08:47:02 UTC
Permalink
liliana.iovanovici [https://community.jboss.org/people/liliana.iovanovici] created the discussion

"How can I take process definitions from Guvnor with jBPM5 API?"

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

--------------------------------------------------------------
Hello,

I want to start a process with JBPM5 wich take the process definitions (.jbpm files) from Guvnor repository.
How can I do this?

Thanks.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/716108#716108]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
liliana.iovanovici
2012-02-13 09:35:09 UTC
Permalink
liliana.iovanovici [https://community.jboss.org/people/liliana.iovanovici] created the discussion

"Re: How can I take process definitions from Guvnor with jBPM5 API?"

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

--------------------------------------------------------------
I allready tried this:

KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("MyAgent");
        kagent.applyChangeSet( ResourceFactory.newUrlResource( http://localhost:8180/guvnor-5.3.0.Final-jboss-as-7.0/org.drools.guvnor.Guvnor/webdav/packages/defaultPackage/ http://localhost:8180/guvnor-5.3.0.Final-jboss-as-7.0/org.drools.guvnor.Guvnor/webdav/packages/defaultPackage/) );
        KnowledgeBase kbase = kagent.getKnowledgeBase();
        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
        ProcessInstance processInstnace =  ksession.startProcess("myProcess.bpmn");
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/716122#716122]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
liliana.iovanovici
2012-02-13 09:36:32 UTC
Permalink
liliana.iovanovici [https://community.jboss.org/people/liliana.iovanovici] created the discussion

"Re: How can I take process definitions from Guvnor with jBPM5 API?"

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

--------------------------------------------------------------
But I got an error:

null: 1, 1): Content is not allowed in prolog.
Exception in thread "main" java.lang.IllegalArgumentException: Unknown process ID: myProcess.bpmn
    at org.jbpm.process.instance.ProcessRuntimeImpl.createProcessInstance(ProcessRuntimeImpl.java:152)

Does anybody know what is the problem?

Thanks.

Liliana
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/716123#716123]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Esteban Aliverti
2012-02-13 09:36:45 UTC
Permalink
Esteban Aliverti [https://community.jboss.org/people/eaa] created the discussion

"Re: How can I take process definitions from Guvnor with jBPM5 API?"

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

--------------------------------------------------------------
In Guvnor, each asset (rule, process, dsl, etc.) has a unique URL that you can use to retrieve its content. Guvnor also keeps a binary (compiled) version of each package containing all its assets that also has a unique URL you can use.

So, in order to get the "source code" of a process "Test" in a pacakge "TestPkg" you can use this URL: http://localhost:8080/drools-guvnor/rest/packages/Workbench/assets/Urine%20Analysis%20Aert/source http://localhost:8080/drools-guvnor/rest/packages/*TestPkg*/assets/*Test*/source
And to get the binary representation of package 'TestPkg': http://localhost:8080/drools-guvnor/rest/packages/TestPkg/binary http://localhost:8080/drools-guvnor/rest/packages/TestPkg/binary

Alternatively, you can also use the new Change-Set editor in Guvnor 5.4 to create a bundle of processes that you want to use together: http://docs.jboss.org/drools/release/5.4.0.Beta2/drools-guvnor-docs/html_single/index.html#d0e1703 http://docs.jboss.org/drools/release/5.4.0.Beta2/drools-guvnor-docs/html_single/index.html#d0e1703

Then you need to add the definitions and/or the packages and put them into a KnowledgeBuilder. Please refer to the documentation to see how this can be done: http://docs.jboss.org/jbpm/v5.2/userguide/ch04.html#d0e655 http://docs.jboss.org/jbpm/v5.2/userguide/ch04.html#d0e655

Best Regards,
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/716124#716124]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
liliana.iovanovici
2012-02-13 13:12:28 UTC
Permalink
liliana.iovanovici [https://community.jboss.org/people/liliana.iovanovici] created the discussion

"Re: How can I take process definitions from Guvnor with jBPM5 API?"

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

--------------------------------------------------------------
Thanks for information Esteban.

I tried to put in my example above the URL: http://localhost:8180/guvnor-5.3.0.Final-jboss-as-7.0/rest/packages/defaultPackage/assets/myProcess/source http://localhost:8180/guvnor-5.3.0.Final-jboss-as-7.0/rest/packages/defaultPackage/assets/myProcess/source .
And when I'm trying to start a process I got an Error: Exception in thread "main" java.lang.IllegalArgumentException: Unknown process ID: com.myProcess.bpmn (Even in the source I had this id: com.myProcess.bpmn):

<process processType="Private" isExecutable="true" id="com.myProcess.bpmn" name="Sample" tns:packageName="defaultPackage" tns:version="4" >

Do you know that is the problem?

Thanks for your help. I'm new in jBPM.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/716176#716176]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Esteban Aliverti
2012-02-13 13:22:03 UTC
Permalink
Esteban Aliverti [https://community.jboss.org/people/eaa] created the discussion

"Re: How can I take process definitions from Guvnor with jBPM5 API?"

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

--------------------------------------------------------------
The source code of a package only contains Drools related assets like rules, functions, etc., but not processes. What you can do is either to use the binary package (you have to build the package first from Guvnor's UI) or to use the process' source URL instead of the package.
Also remember that KnowledgeBuilder doesn't throw any exception if it fails compiling a package. You  have to manually check for errors after you add a resouce by using .hasErrors() and getErrors() methods.

Best Regards,
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/716182#716182]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
liliana.iovanovici
2012-02-14 15:11:10 UTC
Permalink
liliana.iovanovici [https://community.jboss.org/people/liliana.iovanovici] created the discussion

"Re: How can I take process definitions from Guvnor with jBPM5 API?"

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

--------------------------------------------------------------
You had rights. The knowledge base is created only if the entire package built succesfully.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/716548#716548]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Alessandro Dionisi
2012-09-20 08:33:19 UTC
Permalink
Alessandro Dionisi [https://community.jboss.org/people/cecchisandrone] created the discussion

"Re: How can I take process definitions from Guvnor with jBPM5 API?"

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

--------------------------------------------------------------
Can you show a code snippet to read a binary package from Guvnor?
Thanks!
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/760536#760536]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
liliana.iovanovici
2012-09-20 12:57:07 UTC
Permalink
liliana.iovanovici [https://community.jboss.org/people/liliana.iovanovici] created the discussion

"Re: How can I take process definitions from Guvnor with jBPM5 API?"

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

--------------------------------------------------------------
                    KnowledgeAgentConfiguration aconf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
                    KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("testKAgent", aconf);   
                    String fileName = " http://localhost:8180/guvnor-5.3.0.Final-jboss-as-7.0/rest/packages/test/assets/ http://localhost:8180/guvnor-5.3.0.Final-jboss-as-7.0/rest/packages/test/assets/";
                    kagent.applyChangeSet(ResourceFactory.newFileResource(fileName));
                    KnowledgeBase kbase2 = kagent.getKnowledgeBase();
                    StatefulKnowledgeSession ksession2 = kbase2.newStatefulKnowledgeSession();
                    ProcessInstance processInstance = ksession2.startProcess("myProcessTest.bpmn");
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/760588#760588]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Alessandro Dionisi
2012-09-20 14:33:24 UTC
Permalink
Alessandro Dionisi [https://community.jboss.org/people/cecchisandrone] created the discussion

"Re: How can I take process definitions from Guvnor with jBPM5 API?"

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

--------------------------------------------------------------
Thanks liliana, but I can't execute successfully your code (*unable to parse ChangeSet error*).
I've tried to modify your code as follows:

  KnowledgeAgentConfiguration aconf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
                    KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("testKAgent", aconf);
                    String fileName = " http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/plx/LATEST/ChangeSet.xml http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/plx/LATEST/ChangeSet.xml";
                    kagent.applyChangeSet(ResourceFactory.newUrlResource(fileName));
                    KnowledgeBase kbase2 = kagent.getKnowledgeBase();
                    StatefulKnowledgeSession ksession2 = kbase2.newStatefulKnowledgeSession();
                    ProcessInstance processInstance = ksession2.startProcess("plx.SimpleProcess");

But I obtain: *Server returned HTTP response code: 401 for URL: http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/plx/LATEST/ChangeSet.xml http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/plx/LATEST/ChangeSet.xml*

Did you remove authentication from Guvnor?
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/760636#760636]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Zahid Ahmed
2013-04-15 04:54:05 UTC
Permalink
Zahid Ahmed [https://community.jboss.org/people/ahmedza] created the discussion

"Re: How can I take process definitions from Guvnor with jBPM5 API?"

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

--------------------------------------------------------------
Post by Alessandro Dionisi
Post by Alessandro Dionisi
But I obtain: *Server returned HTTP response code: 401 for URL: http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/plx/LATEST/ChangeSet.xml http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/plx/LATEST/ChangeSet.xml*
Did you remove authentication from Guvnor?
You can either remove authentication from your guvnor or pass authentication when you call applyChangeSet(URL url). I am adding the code below.

|
|
| UrlResource urlResource = (UrlResource)ResourceFactory.newUrlResource("http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/plx/LATEST/ChangeSet.xml" ); |
|
|
| urlResource.setBasicAuthentication("enabled"); |
|
|
| urlResource.setUsername("admin"); |
|
|
| urlResource.setPassword("admin"); |
|
|
| kagent.applyChangeSet( urlResource ); |

So here I am using applyChangeSet(URL url) instead of applyChangeSet(String filePath);
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/808225#808225]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Loading...