jBPM4 Hello World

Update 1 feb 2010: hello world update for jBPM 4.3

As promised in my previous post, I’ll show you how easy it is to start using the new jBPM4 API.

I’ll use the mother of all demo’s and implement a process that prints ‘Hello World’ to the screen. One of the core strengths of jBPM has always been the embeddability in several environments (SE, Spring, EJB, etc), so today I’ll show how to create a SE application that uses jBPM as a regular library. I’m going to do the demo with the CR1 release, but the example should be quite protable to the 4.0GA release.

Download the (Maven) example here.

If you want to do it yourself, follow these steps:

  • (non-Maven users): in Eclipse, add jbpm.jar the lib folder of the unzipped distribution to the project classpath.
    (maven-users): create an empty maven project and add the following dependency to your pom.xml:
<dependency>
<groupId>org.jbpm.jbpm4</groupId>
<artifactId>jbpm-jpdl</artifactId>
<version>4.0.CR1</version>
</dependency>
  • Now we’ll create the ‘logic’ of our process. Create a class called Printer :

package be.jorambarrez.jbpm4.helloworld;

public class Printer {

public void printHelloWorld() {
System.out.println("<---------------->");
System.out.println("   HELLO WORLD!");
System.out.println("<---------------->");
}

}

  • Create the HelloWorld process. The process uses a Java activity here to call the ‘printHelloWorld’ method on our ‘business logic’.

<process name="helloWorld" xmlns="http://jbpm.org/4.0/jpdl">
<start>
<transition to="printHelloWorld"/>
</start>

<java class="be.jorambarrez.jbpm4.helloworld.Printer" method="printHelloWorld" name="printHelloWorld">
<transition to="theEnd"/>
</java>

<end name="theEnd" />
</process>

which looks like this if you have installed the GPD:

For JPDL4, one of the main goals is process readability. If you take a look at this process or any of the shipped example processes, you’ll notice that this has worked out quite fine.

  • Create a minimal jBPM config (jbpm.cfg.xml)

<jbpm-configuration>
<import resource="jbpm.default.cfg.xml"/>
<import resource="jbpm.tx.hibernate.cfg.xml"/>
<import resource="jbpm.jpdl.cfg.xml"/>
</jbpm-configuration>

The imports shown here contain a default configuration. If needed, you can remove the imports and configure jBPM for your own environment.

  • Create a basic Hibernate config called jbpm.hibernate.cfg.xml(I’m using HSQLDB, but any DB supported by Hibernate will do):

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>

<property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
<property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="hibernate.connection.url">jdbc:hsqldb:mem:.</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password"></property>

<property name="hibernate.format_sql">true</property>
<property name="hibernate.hbm2ddl.auto">create-drop</property>

<mapping resource="jbpm.repository.hbm.xml" />
<mapping resource="jbpm.execution.hbm.xml" />
<mapping resource="jbpm.history.hbm.xml" />
<mapping resource="jbpm.task.hbm.xml" />
<mapping resource="jbpm.jpdl.hbm.xml" />
<mapping resource="jbpm.identity.hbm.xml" />

</session-factory>
</hibernate-configuration>

Note: if you are using 4.0GA (instead of CR1), remove the ‘jbpm.jpdl.hbm.xml’ line from the hibernate mapping.

and add the correct driver to your classpath. With Maven and HSQLDB, add this dependency to your pom.xml.


<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.7</version>
</dependency>

  • Finally, create a main method which constructs the ProcessEngine

ProcessEngine processEngine = new Configuration().setResource("my.jbpm.cfg.xml").buildProcessEngine();

and retrieve the needed services:


RepositoryService repositoryService = processEngine.getRepositoryService();
ExecutionService executionService = processEngine.getExecutionService();

which we can use to deploy our hello world process and start a process instance


repositoryService.createDeployment()
.addResourceFromClasspath("hello_world.jpdl.xml")
.deploy();
executionService.startProcessInstanceByKey("helloWorld");

After the Hibernate loading, you’ll see the Hello World message from the Printer class.

That’s it, your very first jBPM4 Hello World process. With this setup, you can start playing with the different activities or change the configuration. Do note how easy it is to embed this code into other environments (Spring, EJB, …) due to the fact that jBPM is ‘just another Java library’. Although the hello world process is extremely simple, all the setup around it (jBPM and Hibernate config) are exactly the same as for any arbitrary complex process.

Stay tuned for more posts about jBPM4!

38 Comments

  1. Angel July 3, 2009

    Nice HelloWorld,

    this is a good ‘getting started’. It is necesary because the oficial doc lacks of this kind of doc.

    Thank you very much.

  2. Joram Barrez July 3, 2009

    Angel, the examples of the jBPM distribution contain a similar ‘hello world’ process.

    Just run the demo.setup with ant and you’re all set to go!

  3. thirumal July 17, 2009

    Hi ,
    Hi ,

    I am new to JBPM and need some help .
    In the devguide document it was mentioned as

    “To execute processes without persistence, the client API can be used to work with process and execution objects directly. The client API expose the methods of the core model objects.” .

    We are in need of creating and running a process without persistence .

    I tried going throught the client API javadocs and was not able to figure out a way to create and execute a process .

    Can you point me out the proper direction to look for the samples / documents regarding this.

  4. Anand July 17, 2009

    Hi Jorram,

    Neat stuff, really! Thanks a bunch. Great help for newbies like me. I’m facing a small problem though.

    I’ve used the above maven example with the new jbpm4 release. I’ve had to add a dependency for javax.mail and hibernate in the pom. There’s some activity writing in the db and after which it throws the following error:

    org.jbpm.pvm.internal.wire.WireException: couldn’t initialize object ‘org.jbpm.pvm.internal.repository.RepositorySessionImpl’: proxy class not found: org.jbpm.jpdl.internal.model.JpdlExecution
    at org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor.initialize(ObjectDescriptor.java:233)
    at org.jbpm.pvm.internal.wire.WireContext.performInitialization(WireContext.java:537)
    at org.jbpm.pvm.internal.wire.WireContext.initialize(WireContext.java:499)
    …..

    Any pointers? Thanks

  5. Joram Barrez July 18, 2009

    Anand, try to remove the jbpm.jpdl.hbm.xml from the Hibernate mapping. The JpdlExecution class has been removed for 4.0 GA.

  6. Joram Barrez July 18, 2009

    thirumal, for the moment the API doesn’t work completely without persistence yet.
    If you use the lower-level PVM API, you can do it without persistence (but then you don’t have the goodies from JPDL).

    Memory execution is definitely on our agenda to tackle in one of the next releases!

  7. Anand July 19, 2009

    Hi Jorram,

    Awesome! Worked like a charm! Now that the Hello-World works, guess I need to start figuring out how it all ties together in JBPM4. Again, thanks a bunch!

  8. yoprogramo July 30, 2009

    Hello,

    Your example would be perfect if you continue and explain how to deploy / execute the hello world process…

  9. Joram Barrez July 30, 2009

    @yoprogramo

    In fact, the process is already deployed (deploying = parse it and store it in the database).
    Any other jBPM process engine instance can now use it by pointing its hibernate.cfg.xml to the same database. If you’ve done that, you only need to call executionService.startProcessInstanceByKey(“helloWorld”);

    Another example could be to deploy the example to the database of the jBPM console and start it through there.

  10. yo July 31, 2009

    I have followed all the instructions. My repositoryService instance is null when I run the test program. Please help.

  11. Joram Barrez August 3, 2009

    Try to userforum, which is an easier medium to discuss your problem: http://www.jboss.org/index.html?module=bb&op=viewforum&f=217

  12. OptixPro August 13, 2009

    i have error any one plz help

    Exception in thread “main” org.jbpm.api.JbpmException:
    error: couldn’t parse xml document : org.jbpm.api.JbpmException: resource my.jbpm.cfg.xml does not exist
    at org.jbpm.pvm.internal.xml.ProblemList.getJbpmException(ProblemList.java:168)
    at org.jbpm.pvm.internal.xml.ProblemList.getJbpmException(ProblemList.java:141)
    at org.jbpm.pvm.internal.xml.Parse.checkErrors(Parse.java:189)
    at org.jbpm.pvm.internal.cfg.JbpmConfiguration.parse(JbpmConfiguration.java:165)
    at org.jbpm.pvm.internal.cfg.JbpmConfiguration.setResource(JbpmConfiguration.java:137)
    at org.jbpm.api.Configuration.setResource(Configuration.java:106)
    at be.jorambarrez.jbpm4.helloworld.Main.main(Main.java:13)
    Caused by: org.jbpm.api.JbpmException
    at org.jbpm.pvm.internal.xml.ProblemList.getJbpmException(ProblemList.java:164)
    … 6 more
    Caused by: org.jbpm.api.JbpmException: resource my.jbpm.cfg.xml does not exist
    at org.jbpm.pvm.internal.stream.ResourceStreamInput.openStream(ResourceStreamInput.java:55)
    at org.jbpm.pvm.internal.xml.Parse.getInputSource(Parse.java:145)
    at org.jbpm.pvm.internal.xml.Parser.buildDom(Parser.java:450)
    at org.jbpm.pvm.internal.xml.Parser.execute(Parser.java:387)
    at org.jbpm.pvm.internal.xml.Parse.execute(Parse.java:157)
    … 4 more

    thank you

  13. Joram Barrez August 14, 2009

    @OptixPro: the error is quite descriptive: there is no my.jbpm.cfg.xml on your classpath.

  14. dstl August 19, 2009

    I am trying this example in Eclipse. I put the main method in the Printer.java file and get this error:
    java.lang.NoClassDefFoundError: com/memc/jbpm4/helloworld/Printer
    Caused by: java.lang.ClassNotFoundException: com.memc.jbpm4.helloworld.Printer
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Exception in thread “main”

    Where do you put the main method mentioned? Is it in the Printer.java file?

    Also, do you have any more examples on setting up and using jbpm for 1st time users?

    Thanks and I hope you can help as we would really like to use jbpm at our company.

  15. gabriel August 30, 2009

    Great Post! Thanks!

    for maven-users please add to your pom.xml:

    jboss
    http://repository.jboss.com/maven2

    this made us mad us the very first time with jbpm & maven!

  16. gabriel August 30, 2009

    {code} xml
    repositories
    repository
    id=jboss
    url=http://repository.jboss.com/maven2
    /repository
    /repositories
    {code} xml

  17. Seema September 8, 2009

    Hi

    Thanks for the post..

    My concern is i have created process archive i.e. OrderProcess.jpdl ( ref. user document). This has process.jpdl.xml files with supporting classes.
    Now I want to get them using JNDI lookup.
    Can you please let me know where to mention “OrderProcess.jpdl” in order to get processes by their ids or keys

  18. Prajatna September 24, 2009

    Hi,
    Thanks a lot for this nice example.Currently we are using jBPM 3.2.2 with DB2 in our project . Now we are in analysis phase to migrate it to jBPM 4.0.
    But I could not found the DB script of DB2 UDB in any of the jBPM4 version. can you please let me know, if jBPM4 still support DB2? IF yes, how can I create those jBPM4_xxx tables.

    Thanking you in advance, for your kind response.

  19. Joram September 30, 2009

    @Prajatna: a DB2 script isnt in out distro because we haven’t set up QA for it yet (but it is planned for the near future). So basically there is no ‘official’ support. But since jBPM uses Hibernate under the hood, all should work without problems.

    You can generate the DB2 specific schema by issuing a Hibernate hbbm2ddl command (check our build scripts for a concrete ant task you can use)

  20. Jamil October 30, 2009

    Thank you. It has been a great help.

  21. Roberto November 3, 2009

    Hi everybody
    I have a problem when i try to execute the example:

    Exception in thread “main” java.lang.NullPointerException
        at org.jbpm.pvm.internal.repository.DeploymentImpl.deploy(DeploymentImpl.java:89)
        at
    Is anyone that explain me this kind of problem?
    Thank you very much

  22. Sujatha November 16, 2009

    Hi Jorram,

    Thanks for the wonderful post. When I try to run the Main.java( I am wrapping it as a servlet) I get this following exception..please can you help me..?

    org.jbpm.api.JbpmException: couldn’t instantiate configuration of type org.jbpm.pvm.internal.cfg.ProcessEngineImpl
    org.jbpm.api.Configuration.instantiate(Configuration.java:92)
    org.jbpm.api.Configuration.(Configuration.java:62)
    org.jbpm.api.Configuration.(Configuration.java:51)
    be.jorambarrez.jbpm4.helloworld.Main.doGet(Main.java:31)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

    root cause

    java.lang.ClassCastException: org.jbpm.pvm.internal.cfg.ProcessEngineImpl cannot be cast to org.jbpm.api.Configuration
    org.jbpm.api.Configuration.instantiate(Configuration.java:90)
    org.jbpm.api.Configuration.(Configuration.java:62)
    org.jbpm.api.Configuration.(Configuration.java:51)
    be.jorambarrez.jbpm4.helloworld.Main.doGet(Main.java:31)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

  23. Joe November 17, 2009

    I have same issue as Roberto – NullPointerException deep within deploy().

    Here is my main() method:

    public static void main(String[] args)
    {
    log.info(“BEGIN”);
    try{
    log.info(“Loading JBPM configuration”);
    ProcessEngine engine= new Configuration().setResource(“jbpm.cfg.xml”).buildProcessEngine();
    RepositoryService repo= engine.getRepositoryService();
    ExecutionService exec= engine.getExecutionService();
    log.info(“Deploying process”);
    repo.createDeployment().addResourceFromClasspath(“hello-world.jpdl.xml”).deploy();
    log.info(“Starting process”);
    exec.startProcessInstanceByKey(“helloWorld”);
    log.info(“COMPLETE”);
    }catch(Exception e){
    e.printStackTrace(System.err);
    }finally{
    log.info(“FINALLY”);
    }
    log.info(“END”);
    }// main

    Here is the stack trace and last few lines of my log file:

    INFO: Deploying process
    Nov 16, 2009 5:10:08 PM org.jbpm.internal.log.Jdk14Log info
    INFO: exception while executing command org.jbpm.pvm.internal.cmd.DeployCmd@15c998a
    java.lang.NullPointerException
    at org.jbpm.pvm.internal.repository.RepositorySessionImpl.deploy(RepositorySessionImpl.java:61)
    at org.jbpm.pvm.internal.cmd.DeployCmd.execute(DeployCmd.java:47)
    at org.jbpm.pvm.internal.cmd.DeployCmd.execute(DeployCmd.java:33)
    at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)
    at org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:54)
    at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53)
    at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)
    at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55)
    at org.jbpm.pvm.internal.svc.SkipInterceptor.execute(SkipInterceptor.java:43)
    at org.jbpm.pvm.internal.repository.DeploymentImpl.deploy(DeploymentImpl.java:91)
    at com.mydomain.omega.jbpm.example.HelloWorldApp.main(HelloWorldApp.java:30)
    java.lang.NullPointerException
    at org.jbpm.pvm.internal.repository.RepositorySessionImpl.deploy(RepositorySessionImpl.java:61)
    at org.jbpm.pvm.internal.cmd.DeployCmd.execute(DeployCmd.java:47)
    at org.jbpm.pvm.internal.cmd.DeployCmd.execute(DeployCmd.java:33)
    at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)
    at org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:54)
    at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53)
    at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)
    at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55)
    at org.jbpm.pvm.internal.svc.SkipInterceptor.execute(SkipInterceptor.java:43)
    at org.jbpm.pvm.internal.repository.DeploymentImpl.deploy(DeploymentImpl.java:91)
    at com.mydomain.omega.jbpm.example.HelloWorldApp.main(HelloWorldApp.java:30)

  24. Joe November 17, 2009

    An additional note to my stack trace above, I’m using JBPM 4.2 inside Netbeans 6.7.

  25. Anonymous November 19, 2009

    Please do give more info about the transient variables in jbpm4.2. i just want to know how to make the variables not to be persisted.hope ill get the replies with a good examples. thank you.

  26. Joram November 24, 2009

    @Joe: looks like a configuration error. What is your jbpm.cfg.xml?

    @Anonymous: I’ve found your questions at 4 different places already (my about page, Tom’s blog, etc.). Spamming is NOT the way yo get our attention. Transient variables are planned for a next release, we have the Jira publicly available for this cause.

  27. Anand December 16, 2009

    Hi… I have a little problem while executing the examples that are present with jbpm4.0

    org.jbpm.pvm.internal.wire.WireException: couldn’t initialize object ‘org.jbpm.pvm.internal.repository.RepositorySessionImpl’: Could not parse configuration: jbpm.hibernate.cfg.xml

  28. Tifr December 16, 2009

    hi ..

    i have been facing this problem from last two days….but still i could not solve this problem …..Please help in this problem

    While i am deploying the files i am getting the error like

    org.hibernate.exception.GenericJDBCException: could not insert: [org.jbpm.pvm.internal.lob.Lob]

    Help in solving this problem …… 🙂

  29. Anonymous December 16, 2009

    hi …..
    i have been facing the problem with jbpm4.0 + jboss 5.0 + jdk 1.6

    required help to solve this

    …..

    Dec 16, 2009 5:38:31 PM org.jbpm.internal.log.Jdk14Log info
    [jbpm-deploy] INFO: exception while executing command org.jbpm.pvm.internal.cmd.DeployCmd@d3c69c
    [jbpm-deploy] java.lang.NullPointerException
    [jbpm-deploy] at org.jbpm.pvm.internal.repository.RepositorySessionImpl.deploy(RepositorySessionImpl.java:55)
    [jbpm-deploy] at org.jbpm.pvm.internal.cmd.DeployCmd.execute(DeployCmd.java:46)
    [jbpm-deploy] at org.jbpm.pvm.internal.cmd.DeployCmd.execute(DeployCmd.java:32)
    [jbpm-deploy] at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)
    [jbpm-deploy] at org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:54)
    [jbpm-deploy] at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:54)
    [jbpm-deploy] at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55)
    [jbpm-deploy] at org.jbpm.pvm.internal.repository.DeploymentImpl.deploy(DeploymentImpl.java:89)
    [jbpm-deploy] at org.jbpm.pvm.internal.ant.JbpmDeployTask.deployFile(JbpmDeployTask.java:110)
    [jbpm-deploy] at org.jbpm.pvm.internal.ant.JbpmDeployTask.execute(JbpmDeployTask.java:60)
    [jbpm-deploy] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    [jbpm-deploy] at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    [jbpm-deploy] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [jbpm-deploy] at java.lang.reflect.Method.invoke(Method.java:597)
    [jbpm-deploy] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [jbpm-deploy] at org.apache.tools.ant.Task.perform(Task.java:348)
    [jbpm-deploy] at org.apache.tools.ant.Target.execute(Target.java:357)
    [jbpm-deploy] at org.apache.tools.ant.Target.performTasks(Target.java:385)
    [jbpm-deploy] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
    [jbpm-deploy] at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
    [jbpm-deploy] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    [jbpm-deploy] at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
    [jbpm-deploy] at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
    [jbpm-deploy] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
    [jbpm-deploy] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)

  30. Joram December 28, 2009

    @Anand: the error is quite obvious, there is something wrong with your jbpm.hibernate.cfg.xml config.

    @Tifr: No clue without a stacktrace, environment, etc. These kind of questions are better asked on the user forum, since they will benefit other users too.

    @Anonymous: Try to use the latest version (4.2, very soon 4.3). A lot of things have changed in the meanwhile.

  31. Ganesh Gowtham January 11, 2010

    Hi Joram ,

    I want to install Jbpm Console(4.1) in Weblogic 10.3 .
    Do you any links (or) doc which explains me in details how ti install JBPM in Weblogic ? as Ant build file lacks task for weblogic .

  32. ali January 14, 2010

    Thanks a lot, helped me to quickly use the processing engine! Now only if this was included in the official JBoss documentation.

  33. Abhishek March 4, 2010

    Great Tutorial. I got the head start.

  34. roberto March 30, 2010

    Does anyone have an example a little more complicated than HelloWorld to show me!
    I am in difficulty in the use of jBPM.
    I have seen examples on the official website but they are too little complex 🙁
    my e-mail romodem@libero.it

  35. Chaitanya Desai April 16, 2010

    I get this exception when I try to run jbpm 4.3 sample codes :

    0:34:18,759 INF | [DefaultCommandService] exception while executing command org.jbpm.pvm.internal.cmd.CheckDbCmd@861f24
    org.jbpm.api.JbpmException: couldn’t instantiate hibernate configuration class org.hibernate.cfg.Configuration
    at org.jbpm.pvm.internal.wire.descriptor.HibernateConfigurationDescriptor.construct(HibernateConfigurationDescriptor.java:64)
    at org.jbpm.pvm.internal.wire.WireContext.construct(WireContext.java:469)
    at org.jbpm.pvm.internal.wire.WireContext.create(WireContext.java:448)
    at org.jbpm.pvm.internal.wire.WireContext.create(WireContext.java:437)
    at org.jbpm.pvm.internal.wire.WireContext.get(WireContext.java:417)
    at org.jbpm.pvm.internal.wire.WireContext.get(WireContext.java:327)
    at org.jbpm.pvm.internal.wire.WireContext.get(WireContext.java:688)
    at org.jbpm.pvm.internal.wire.descriptor.HibernateSessionFactoryDescriptor.construct(HibernateSessionFactoryDescriptor.java:57)
    at org.jbpm.pvm.internal.wire.WireContext.construct(WireContext.java:469)
    at org.jbpm.pvm.internal.wire.WireContext.create(WireContext.java:448)
    at org.jbpm.pvm.internal.wire.WireContext.create(WireContext.java:437)
    at org.jbpm.pvm.internal.wire.WireContext.get(WireContext.java:417)
    at org.jbpm.pvm.internal.wire.WireContext.get(WireContext.java:327)
    at org.jbpm.pvm.internal.wire.WireContext.get(WireContext.java:688)
    at org.jbpm.pvm.internal.env.BasicEnvironment.get(BasicEnvironment.java:139)
    at org.jbpm.pvm.internal.env.BasicEnvironment.get(BasicEnvironment.java:130)
    at org.jbpm.pvm.internal.wire.descriptor.HibernateSessionDescriptor.construct(HibernateSessionDescriptor.java:63)
    at org.jbpm.pvm.internal.wire.WireContext.construct(WireContext.java:469)
    at org.jbpm.pvm.internal.wire.WireContext.create(WireContext.java:448)

    ……..

    Caused by: java.lang.ExceptionInInitializerError
    at org.hibernate.cfg.Configuration.reset(Configuration.java:201)
    at org.hibernate.cfg.Configuration.(Configuration.java:220)
    at org.hibernate.cfg.Configuration.(Configuration.java:224)
    … 60 more
    Caused by: java.lang.NullPointerException
    at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:167)
    at org.hibernate.cfg.Environment.(Environment.java:558)
    … 63 more

    Can you suggest how do I rectify this …

    -Regards,

  36. […] However, there were some very good resources on integrating JBPM with a spring application. I found Joram Barrez’s Hello World Example very helpful and was able to integrate using the following […]

  37. blogging to make money July 12, 2010

    Good work! Your post is an excellent example of why I keep coming back to read your excellent quality content that is forever updated. Thank you!

  38. Gun July 21, 2010

    Hello Joram,
    Your tutorial is perfect except that I’m facing a little problem while execution the application. Here is the console output. I hope you have a solution.
    Hello World!
    21 juil. 2010 10:05:46 org.hibernate.util.JDBCExceptionReporter logExceptions
    ATTENTION: SQL Error: 1451, SQLState: 23000
    21 juil. 2010 10:05:46 org.hibernate.util.JDBCExceptionReporter logExceptions
    GRAVE: Cannot delete or update a parent row: a foreign key constraint fails (`jbpm/jbpm4_execution`, CONSTRAINT `FK_EXEC_INSTANCE` FOREIGN KEY (`INSTANCE_`) REFERENCES `jbpm4_execution` (`DBID_`))
    21 juil. 2010 10:05:46 org.hibernate.event.def.AbstractFlushingEventListener performExecutions
    GRAVE: Could not synchronize database state with session
    org.hibernate.exception.ConstraintViolationException: could not delete: [org.jbpm.pvm.internal.model.ExecutionImpl#7]
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2569)
    at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2725)
    at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:97)
    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:172)
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
    at org.jbpm.pvm.internal.tx.HibernateSessionResource.prepare(HibernateSessionResource.java:56)
    at org.jbpm.pvm.internal.tx.StandardTransaction.commit(StandardTransaction.java:107)
    at org.jbpm.pvm.internal.tx.StandardTransaction.complete(StandardTransaction.java:64)
    at org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:61)
    at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53)
    at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)
    at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55)
    at org.jbpm.pvm.internal.svc.SkipInterceptor.execute(SkipInterceptor.java:43)
    at org.jbpm.pvm.internal.svc.ExecutionServiceImpl.startProcessInstanceByKey(ExecutionServiceImpl.java:66)
    at ma.gfit.jbpm.Test.main(Test.java:16)
    Caused by: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`jbpm/jbpm4_execution`, CONSTRAINT `FK_EXEC_INSTANCE` FOREIGN KEY (`INSTANCE_`) REFERENCES `jbpm4_execution` (`DBID_`))
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:931)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2941)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1623)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1715)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:3249)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1268)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1541)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1455)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1440)
    at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2551)
    … 18 more
    Exception in thread “main” org.hibernate.exception.ConstraintViolationException: could not delete: [org.jbpm.pvm.internal.model.ExecutionImpl#7]
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2569)
    at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2725)
    at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:97)
    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:172)
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
    at org.jbpm.pvm.internal.tx.HibernateSessionResource.prepare(HibernateSessionResource.java:56)
    at org.jbpm.pvm.internal.tx.StandardTransaction.commit(StandardTransaction.java:107)
    at org.jbpm.pvm.internal.tx.StandardTransaction.complete(StandardTransaction.java:64)
    at org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:61)
    at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53)
    at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)
    at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55)
    at org.jbpm.pvm.internal.svc.SkipInterceptor.execute(SkipInterceptor.java:43)
    at org.jbpm.pvm.internal.svc.ExecutionServiceImpl.startProcessInstanceByKey(ExecutionServiceImpl.java:66)
    at ma.gfit.jbpm.Test.main(Test.java:16)
    Caused by: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`jbpm/jbpm4_execution`, CONSTRAINT `FK_EXEC_INSTANCE` FOREIGN KEY (`INSTANCE_`) REFERENCES `jbpm4_execution` (`DBID_`))
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:931)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2941)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1623)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1715)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:3249)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1268)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1541)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1455)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1440)
    at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2551)

Leave a Reply

Your email address will not be published. Required fields are marked *