0 Replies Latest reply on Nov 19, 2006 10:47 AM by froschfinger

    Integrating JBPM in web application

    froschfinger

      Hi,
      i want to integrate JBPM in my web application. I wrote a servlet which starts a process with an action handler. But if i deploy this in my Jboss it occurs a ClassNotFoundException. My Actionhandler is in the same directory and i dont understand it. Could somebody give me some hints?

      My Servlet:


      
      import java.io.IOException;
      
      import javax.servlet.ServletException;
      import javax.servlet.http.HttpServletRequest;
      import javax.servlet.http.HttpServletResponse;
      
      import org.jbpm.JbpmConfiguration;
      import org.jbpm.JbpmContext;
      import org.jbpm.graph.def.ProcessDefinition;
      import org.jbpm.graph.exe.ProcessInstance;
      
      /**
       * Servlet implementation class for Servlet: TestServlet
       *
       */
       public class TestServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
       /* (non-Java-doc)
       * @see javax.servlet.http.HttpServlet#HttpServlet()
       */
       public TestServlet() {
       super();
       }
      
       /* (non-Java-doc)
       * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
       */
       protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      
       JbpmConfiguration jbpmConfig=JbpmConfiguration.parseXmlString(
       "<jbpm-configuration>"+
      
      
      
       "</jbpm-configuration>");
      
      
      
      
       JbpmContext context=jbpmConfig.createJbpmContext();
      
       try {
       ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
       "<process-definition>" +
       " <start-state>" +
       " <transition to='s'>" +
       " <action name='action' class='MyActionHandler'>"+
       " <message>Going to the first state!</message>"+
       " </action>"+
       " </transition>"+
       " </start-state>" +
       " <state name='s'>" +
       " <transition to='end' />" +
       " </state>" +
       " <end-state name='end' />" +
       "</process-definition>"
       );
      
       ProcessInstance processInstance =
       new ProcessInstance(processDefinition);
      
       // After construction, the process execution has one main path
       // of execution (=the root token).
       processInstance.signal();
      
       // Also after construction, the main path of execution is positioned
       // in the start-state of the process definition.
      
       // Let's start the process execution, leaving the start-state
       // over its default transition.
      
       // The signal method will block until the process execution
       // enters a wait state.
       processInstance.end();
      
       }finally{
       context.close();
       }
       }
       protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      
       }
      }


      My ActionHandler:



      import org.jbpm.graph.def.ActionHandler;
      import org.jbpm.graph.exe.ExecutionContext;
      
      
      public class MyActionHandler implements ActionHandler{
      
       /**
       *
       */
       private static final long serialVersionUID = 1L;
      
       public void execute(ExecutionContext arg0) throws Exception {
      
       System.out.println("######################");
       System.out.println("Mail senden");
       System.out.println("######################");
       }
      
      }


      Is there a special File hierarchy which i have to use?