1 2 Previous Next 20 Replies Latest reply on Mar 13, 2014 2:28 PM by Guy Rouillier

    Swing application for jBPM 6

    Tan Vu Newbie

      So I have the jBPM 6 demo up and running.  I would like to write a java swing application that would interact with the demo project such as displaying all the process definitions, deployments, start a process...How do I do this?  Any documentation on this?


      Thank you,



        • 1. Re: Swing application for jBPM 6
          Maciej Swiderski Master

          two ways:

          • use REST or JMS remoting capabilities provided by web tooling - see docs for details
          • integrate directly on data base level - embed jbpm into swing application and congiure it to the same data base as the web tooling


          • 2. Re: Swing application for jBPM 6
            Tan Vu Newbie

            So jBPM 6 does not have Java Engine APIs? 

            • 3. Re: Swing application for jBPM 6
              Mauricio Salatino Master

              Hi Tan,

              Yes jBPM provides the java apis to interact with it, but you will need to configure all the runtime environments.

              Maciej was suggesting as a first option to interact via rest or JMS because that will provide you out of the box all the runtime environments already configured for you to start working.


              If you want to embed jBPM inside your application (he also offer this as a second option) you just need to include the jbpm dependencies in your application and then configure the runtime environments to use the same database that the tooling is using. If you don't really want to use the tooling you just configure jbpm to use your defined database to store the process executions.


              Take a look at the documentation to see how to configure the runtime environments and the persistence unit for embedding jbpm into your app.

              • 4. Re: Swing application for jBPM 6
                Tan Vu Newbie

                Thank Mauricio.  I did go to jBPM 6 User Guide and look at the Core Engine



                However,  it does not give me all the configuration info needed to set up my application.  Is there any other supported document on this subject somewhere else?  Better yet, Is there a sample eclipse project?


                Thank you,



                • 5. Re: Swing application for jBPM 6
                  Mauricio Salatino Master

                  Are you using Maven? you need to add the jbpm-bom to your project and then configure the persistence unit.

                  There are not tutorials for doing that because each application will require different configurations and different dependencies based on what you are doing to do.

                  You can start simple and making sure that all the pieces are correct. If you have already your swing application you will only need to worry about the jbpm dependencies.

                  Because jBPM can be embedded in any java app it's up to you to set it up accordingly. And because jBPM is not tied to any IDE, meaning that you can use it no matter the IDE,  don't expect to find IDE related things..

                  • 6. Re: Swing application for jBPM 6
                    Andreas G. Novice

                    Does "integrate directly on database level" mean that process definitons and process deployments are stored in a database table instead of using a git and a maven repository?


                    I am using JBPM4.4 processes in an web application. The process definitions are stored in JBPM database tables. I want to upgrade JBPM4.4 to JBPM6 but I don't want to use git and maven repositories. Does JBPM6 provides an API for saving and deploying processes to a database like JBPM4.4? If not, can you give me a hint how I can achieve this? Just store the binary data of the process definitions in a database table?

                    • 7. Re: Swing application for jBPM 6
                      Tan Vu Newbie

                      Maybe I was not clear of what I want to accomplish.  I would like to write a Java Swing that interact with the "demo" project:

                      1.  Users will still use "demo" jBPM console to create processes, build, deploy, start a process...

                      2.  My Swing application will "connect" to the "demo" project, and use Java APIs to get whatever information I need such as number of deployments, process definitions, list of forms for a process definitions...


                      The info I need is the configuration to let my swing application "connect" to the "demo" jBPM project.  I can't find it anywhere.  Or maybe I have the wrong approach? 

                      Before working with jBPM, I worked with Activiti & Bonitasoft.  This is how it works in both cases: I have a configuration files that would give me all the configuration info so that I can instantiate an engine object that connects to whatever database I want to connect to (in this case would be the H2 for "demo" project).  Once I have the engine object, I can just start using all the APIs associate with it.


                      Thank you,



                      • 8. Re: Swing application for jBPM 6
                        Mauricio Salatino Master

                        That's exactly what Maciej second option was proposing.

                        • integrate directly on data base level - embed jbpm into swing application and congiure it to the same data base as the web tooling

                        Where the file that you mention is the persistence.xml which says where the database is. If you are planning to use the same application from multiple places I would recommend you to change the backend database to MySql or Postgres, they will provide more tools that will allow you to know what is going on under the hoods.


                        Notice that this is not the same that Andreas G. was mentioning in his question, where he doesn't want to use git or maven.

                        Also notice that from your swing application you can interact using the rest endpoints which also add some very different advantages:

                        1) if you don't want to add all the configurations about the database, deployments etc.. the rest endpoint is easier.

                        2) Usually it is better to keep the configuration in one place (not in multiple applications to maintain) so the rest/jms seems a clear approach.


                        Look at this example here: droolsjbpm/jbpm-playground · GitHub called -> jbpm-simple-rest-client which is basically a set of java classes that gives you the "Engine Object" as you mention to interact with KIE-WB via rest.

                        • 9. Re: Swing application for jBPM 6
                          Tan Vu Newbie

                          So, I gave up on Java APIs (for now) and start exploring REST API instead per your recommendation.  I went to the link you provided, download the jbpm-simple-rest-client.

                          Errors in the class SimpleRestClient:


                          RemoteRestSessionFactory restSessionFactory

                                      = new RemoteRestSessionFactory(deploymentId, appUrl, user, password); 

                          Replace it with:

                            RemoteRestRuntimeFactory restSessionFactory

                                       = new RemoteRestRuntimeFactory(deploymentId, appUrl, user, password);


                          2.  URL appUrl = new URL("http://localhost:8080/kie-wb/");


                               Replace it with:

                               URL appUrl = new URL("http://localhost:8080/jbpm-console/");


                          After fixing those, I went to demo and deploy the Evaluation process.  I got the "org.jbpm:Evaluation:1.0" for deploymentId.  I then started two processes.  I verified it by open the Process Instances view and see two items on the list.  I also went to the database, and see two items in processintanceinfo table.


                          In the SimipleRestClient, I add this line of code:

                               Collection<ProcessInstance> processInstances = ksession .getProcessInstances();

                          then I print out in the console:

                               System.out.println("MyRestEngine.processInstances.size: "  + processInstances.size());


                          In console:  MyRestEngine.processInstances.size: 0


                          Also, another problem:

                               ProcessInstance processInstance = ksession.getProcessInstance(1);

                               System.err.println("MyRestEngine.processName: "  + processInstance.getProcessName());


                          In console:  Exception in thread "main" java.lang.UnsupportedOperationException: getProcessName is not supported on the JAXB ProcessInstance implementation.



                          What did I do wrong?  or these are bugs in jBPM 6 REST API?


                          Thank you,







                          • 10. Re: Swing application for jBPM 6
                            Prateek Mehra Newbie

                            Hi Tan,


                            I also got this exception. I used the REST API, accessing the REST calls using org.apache.http package. I was able to start a process successfully using the API but while trying to retrieve the details like the process id, process state and process name for the process that I started, I got this exception. I got the details by parsing the xml returned from the http response getcontent() and created an instance of JaxbProcessInstanceResponse, setting its Id, ProcessId and State.

                            But when I tried to retrieve these parameters including the name, it throws this exception for the name. I think if a parameter is null in the JAXB class, it will fail if you try and invoke the get method. Did you try accessing the other attributes like the process id and state?




                            • 11. Re: Swing application for jBPM 6
                              Tan Vu Newbie

                              Hi Prateek,


                              No, I gave up on this issue unless somebody jBPM can give me further information.  It seems as if jBPM6 documentation is not very good and the help from the community is not robust.  I am saying this from my experience with BonitaSoft & Activiti.  So far, I have not found a good example (that would work) from jBPM6 to test out Java APIs core engine.  I wish jBPM6 team would come up with one good example (means no bug, all dependencies should be valid) and let beginners like me to try it out and build confidence.



                              • 12. Re: Swing application for jBPM 6
                                Mauricio Salatino Master

                                Hi Tan, can you please clarify what are you trying to achieve?

                                Are you looking for the REST APIs or the Java APIs?

                                we are working hard on get the new release done. Remember that this is a community project so if there is not enough documentation the community should provide it, the same with examples we cannot do all that work alone. So contributions are always welcome.

                                I consider a better approach to start building what you need and report back here the problems/exceptions that you encounter, attaching projects to reproduce the issues and tests. In that way it is a lot easier for us to reproduce and help the community with their projects.



                                • 13. Re: Swing application for jBPM 6
                                  Tan Vu Newbie

                                  Hi Mauricio,


                                  "I consider a better approach to start building what you need and report back here the problems/exceptions that you encounter, attaching projects to reproduce the issues and tests."


                                  I did exactly what you said in my previous post on Feb 18th.


                                  I would like to just have a simple swing that would let me explore Java APIs through the "demo" project.  When I search for documentation, I could not find any information on how to set up a java application that would connect to the H2 database used in "demo" project.  I brought this up, and somebody told me instead of trying Java APIs, trying to work with REST APIs instead (which doesn't require my application to connect to database).  I am like fine, I'll try that then.  But the example in droolsjbpm/jbpm-playground · GitHub called -> jbpm-simple-rest-client has so many bugs that I have to do more research to make it compiled.  And once it compiled, I run and it gave me run time error.  I posted everything I did and errors in my previous post on here but never heard from anyone since.


                                  So ultimately, I would like a very simple java application that would let me communicate with the "demo" project and let me start exploring Java APIs.  Is there a reliable example, or instruction on how to set it up?  I use Maven so I should have all dependencies needed.  I just don't know how to configure so that my application would talk with "demo" project through Java APIs.


                                  Thank you so much,




                                  PS:   In case you wonder what did not work, I post my application (to use REST APIs):


                                  package engine;



                                  import java.net.MalformedURLException;

                                  import java.net.URL;

                                  import java.util.Collection;



                                  import org.kie.api.runtime.KieSession;

                                  import org.kie.api.runtime.manager.RuntimeEngine;

                                  import org.kie.api.runtime.process.ProcessInstance;

                                  import org.kie.api.task.TaskService;

                                  import org.kie.services.client.api.RemoteRestRuntimeFactory;




                                  * This is a very simple Rest Client to test against a running instance of the

                                  * KIE Workbench. You can parameterize - the Deployment Unit Id - the

                                  * Application URL - the user/pass to execute operations


                                  public class MyRestEngine {



                                    public static void main(String[] args) throws MalformedURLException {

                                    String deploymentId = "org.jbpm:Evaluation:1.0";

                                    URL appUrl = new URL("http://localhost:8080/jbpm-console/");

                                    String user = "eric";

                                    String password = "eric";



                                    RemoteRestRuntimeFactory restSessionFactory = new RemoteRestRuntimeFactory(

                                    deploymentId, appUrl, user, password);

                                    RuntimeEngine engine = restSessionFactory.newRuntimeEngine();



                                    KieSession ksession = engine.getKieSession();

                                    TaskService taskService = engine.getTaskService();

                                    ProcessInstance processInstance1 = ksession.getProcessInstance(1);

                                    System.err.println("MyRestEngine.processName: "

                                    + processInstance1.getProcessName());



                                    Collection<ProcessInstance> processInstances = ksession




                                    System.err.println("MyRestEngine.processInstances.size: "

                                    + processInstances.size());

                                    for (ProcessInstance processInstance : processInstances) {

                                    System.err.println("MyRestEngine.processInstanceName: "

                                    + processInstance.getProcessName());





                                  • 14. Re: Swing application for jBPM 6
                                    Mauricio Salatino Master

                                    Let's build something from the community perspective so it can be used for other people.

                                    What was the problem with the code that you pasted?

                                    I notice that you are iterating the process instances and then looking for the name of the process.

                                    Not all the data is exposed via rest so let's see if we can get all you need.

                                    We can build up a simple swing app besides the Simple Rest Client example to achieve what you need? Does it sounds as a good idea?

                                    I need to update myself also into the Rest interface so it is a good excuse to take a look on it together and build up a good example for the community.

                                    Can you clone the jbpm-playground repository? Do you know how to send pull requests?

                                    I can create the base projects so you can send contributions there as well.



                                    1 2 Previous Next