2 Replies Latest reply on Nov 24, 2014 8:46 PM by Adam George

    Start jbpm process through a Servlet

    Domenico Schiavone Newbie

      Hi all,

      i have a simple process that execute any script task. I make this with a simple JAR.

      Now i want to run this process through a servlet.

      I've created a Dynamic web project with a simple servlet into.

      how i can start the process?

      the code in to the process main of JAR file is:


      package com.sample;


      import java.util.List;


      import javax.persistence.EntityManagerFactory;

      import javax.persistence.Persistence;


      import org.jbpm.test.JBPMHelper;

      import org.kie.api.KieBase;

      import org.kie.api.KieServices;

      import org.kie.api.runtime.KieContainer;

      import org.kie.api.runtime.KieSession;

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

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

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

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


      public class ProcessMain {


          public static void main(String[] args) {

              KieServices ks = KieServices.Factory.get();

              KieContainer kContainer = ks.getKieClasspathContainer();

              KieBase kbase = kContainer.getKieBase("kbase");


              RuntimeManager manager = createRuntimeManager(kbase);

              RuntimeEngine engine = manager.getRuntimeEngine(null);

              KieSession ksession = engine.getKieSession();









          private static RuntimeManager createRuntimeManager(KieBase kbase) {



              EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa");

              RuntimeEnvironmentBuilder builder = RuntimeEnvironmentBuilder.Factory.get()



              return RuntimeManagerFactory.Factory.get()

                  .newSingletonRuntimeManager(builder.get(), "com.sample:example:1.0");





      If I copy the code of the main class into the serlvet class the same i don't know where take the bpmn file into the dynamic web project.

      the structure of the web project is:


      - ProjectName

           + Jax-ws web services

           +Deployment descriptor:

           - Java resources

                - src




           +JavaScript Resources