6 Replies Latest reply on Sep 15, 2005 3:08 PM by crina

    process invoked from a web application

    crina

      I am trying to deploy a web application which invokes a process definition using this code:

       JbpmSessionFactory jbpmSessionFactory =
       JbpmSessionFactory.buildJbpmSessionFactory();
       jbpmSession = jbpmSessionFactory.openJbpmSession();
       jbpmSession.beginTransaction();
       ProcessDefinition definition =
      jbpmSession.getGraphSession().findLatestProcessDefinition(processName);
       instance = new ProcessInstance(definition);
       instance.signal();
       ...


      The process definition is deployed in hsqldb using deploypar. My issue is: cannot find the classes refered directly or indirectly from process definition, while running the webapplication. For example:

      1) if the action handler classes are not deployed in the JBPM tables (hsqldb), I get an error:
      action threw exception: couldn't get value for file 'classes/com/test/TestActionHandler.class'
      2) if the action handler class is deployed in the JBPM tables (hsqldb) and it extends a class BaseTestActionHandler, I get the following error:
      couldn't get value for file 'classes/com/test/BaseTestActionHandler.class'
      3) if I put both action handler and base class in the JBPM tables (hsqldb) and BaseTestActionHandler.class uses a Spring framework, I get this error:
      couldn't get value for file 'classes/org/springframework/context/support/ClassPathXmlApplicationContext'

      ----
      I tried to put the above classes (when they are not deployed in the JBPM tables) under directory WEB-INF/classes or packed in jar in WEB-INF/lib of the war. I even tried to put them in the default/lib of JBoss. The classes still couldn't be found. What am I doing wrong?

      Thanks,
      Crina

        • 1. Re: process invoked from a web application
          crina

          I'm trying now with a very simple example:

          1) simple.par - contains only the pocessdefinition.xml. I deploy it to db. The pocessdefinition.xml contains only one ActionHandler: com/sample/action/FileActionHandler

          2) the war contains:
          - web-inf/classes/com/sample/servlet/WorkflowServlet.class
          - web-inf/web.xml
          - meta-inf/manifest.mf
          - web-inf/lib/simple.jar

          where simple.jar contains:
          - com/sample/action/FileActionHandler.class
          - meta-inf/manifest.mf

          (The manifest.mf don't contain anything specific)

          WorkflowServlet.java is defined as follow:

          public class WorkflowServlet extends HttpServlet {
          
           private static final long serialVersionUID = 1L;
           static JbpmSessionFactory jbpmSessionFactory =
           JbpmSessionFactory.buildJbpmSessionFactory();
          
           public void doGet(HttpServletRequest request, HttpServletResponse response)
           {
           try
           {
           JbpmSession jbpmSession = jbpmSessionFactory.openJbpmSession();
           jbpmSession.beginTransaction();
           ProcessDefinition definition = jbpmSession.getGraphSession().findLatestProcessDefinition("simple");
           System.out.println("Definition is:" + definition);
           ProcessInstance instance = new ProcessInstance(definition);
           System.out.println("starting the process" + instance.getRootToken().getNode().getName());
           instance.signal();
           System.out.println( "Instance is in ending"+ instance.getRootToken().getNode().getName());
           System.out.println("Instance has ended" + instance.hasEnded());
           jbpmSession.getGraphSession().saveProcessInstance(instance);
           jbpmSession.commitTransaction();
           jbpmSession.close();
          
           response.setContentType("text/html");
           PrintWriter out = response.getWriter();
           out.println("success");
           out.close();
           } catch (Exception e)
           {
           e.printStackTrace();
           }
          }


          As in my fist posting it cannot reach the class FileActionHandler I am getting this error:
          11:27:41,003 INFO [STDOUT] Caused by: java.lang.RuntimeException: couldn't getvalue for file 'classes/com/sample/action/FileActionHandler.class'
          11:27:41,003 INFO [STDOUT] at org.jbpm.file.def.FileDefinition.getBytes(FileDefinition.java:160)
          11:27:41,003 INFO [STDOUT] at org.jbpm.instantiation.ProcessClassLoader.findClass(ProcessClassLoader.java:34)
          11:27:41,003 INFO [STDOUT] at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
          11:27:41,003 INFO [STDOUT] at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
          11:27:41,003 INFO [STDOUT] at org.jbpm.instantiation.Delegation.instantiate(Delegation.java:105)
          11:27:41,003 INFO [STDOUT] at org.jbpm.instantiation.Delegation.getInstance(Delegation.java:90)
          11:27:41,003 INFO [STDOUT] at org.jbpm.graph.def.Action.execute(Action.java:78)
          11:27:41,003 INFO [STDOUT] at org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:186)
          11:27:41,003 INFO [STDOUT] ... 35 more
          11:27:41,003 INFO [STDOUT] Caused by: java.lang.RuntimeException: file 'classes
          /com/sample/action/FileActionHandler.class' not found in db
          11:27:41,003 INFO [STDOUT] at org.jbpm.file.def.FileDefinition.getByteArray(FileDefinition.java:184)
          11:27:41,003 INFO [STDOUT] at org.jbpm.file.def.FileDefinition.getBytesFromDb(FileDefinition.java:176)
          11:27:41,003 INFO [STDOUT] at org.jbpm.file.def.FileDefinition.getBytes(FileDefinition.java:157)
          11:27:41,019 INFO [STDOUT] ... 42 more


          Is there a way I can put the action hadlers in the war instead of JBPM tables? If I deploy the FileActionHandler in db along with simple.par then it works. I saw in these forums that it is possible to put the handlers in the WEB-INF/lib, but for me it's not working. I'll be fine to put this action handlers in db, but if they use spring then it complains that cannot find the spring in db (see my first posting). It would be wierd to put spring in db.

          Your help would be appreciated,
          thanks,
          Crina

          • 2. Re: process invoked from a web application
            kukeltje

            If you have the jbpm.sar, and run a recent jboss AS (>4.02 afaik) there is no unified classloader by default anymore. The jbpm classes are outside the war and can never find the classes in the jar that is included in the war.

            Either:
            - turn on the old jboss unified classloader (look at the jboss site for this)
            - put the classes on the classpath outside the war
            - put the classes in the par
            - do not use the jbpm.sar but include the jbpm classes in the war as well.

            hth,

            Ronald

            • 3. Re: process invoked from a web application

              Way off topic, but if anybody has a good pointer to docs on the removal of the unified classloader, etc, please point me on to them. Looking at the docs on the regular site...

              http://docs.jboss.org/jbossas/jboss4guide/r3/html/ch2.chapter.html#d0e1806

              I don't see anything about that removal. That doc is 4.0.2, so if you actually mean >, this would be in as of yet unreleased versions?

              • 4. Re: process invoked from a web application
                kukeltje
                • 5. Re: process invoked from a web application
                  kukeltje

                  and the UCL is not removed, it is just not the default anymore.

                  • 6. Re: process invoked from a web application
                    crina

                    Thanks and much appreciated for response. It did work!
                    I chose the 4th solution: do not use the jbpm.sar but include the jbpm classes in the war as well.
                    So I put the jars from jbpm.sar in the war, I kept the action handlers in db but the classes that the actions refer to or extends from are in war.
                    Thanks again,
                    Crina