5 Replies Latest reply on Apr 12, 2006 2:34 AM by koen.aers

    how to specify external jar files for ActionHandlers

    shavianshakes

      Hi,

      I am trying to implement an ActionHandler which uses a class from third party jar file. Where should I specify the path to the third party jar files ? I tried adding the jars in the $JAVA_HOME/jre/lib directory, and also adding them in various lib directories under the jbpm directory. But when the action is executed, the classloader is not able to find the jar file. I see errors in the log like :

      935 Caused by: org.jbpm.JbpmException: couldn't get value for file 'classes/com/jareva/zcil/client/SPLSession.class'
      936 at org.jbpm.file.def.FileDefinition.getBytes(FileDefinition.java:186)
      937 at org.jbpm.instantiation.ProcessClassLoader.findClass(ProcessClassLoader.java:55)
      938 at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
      939 at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
      940 at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
      941 at com.jbay.action.ListSoftware.execute(ListSoftware.java:19)
      942 at org.jbpm.graph.def.Action.execute(Action.java:123)
      943 at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:235)
      944 ... 62 more
      945 Caused by: org.jbpm.JbpmException: file 'classes/com/jareva/zcil/client/SPLSession.class' not found in db
      946 at org.jbpm.file.def.FileDefinition.getByteArray(FileDefinition.java:210)
      947 at org.jbpm.file.def.FileDefinition.getBytesFromDb(FileDefinition.java:202)
      948 at org.jbpm.file.def.FileDefinition.getBytes(FileDefinition.java:183)


      btw I am using the jbpm starters kit 3.1 beta 3. Do I need to put the jars in some specific dir or add their locationin some config file.

      thanks.

        • 1. Re: how to specify external jar files for ActionHandlers
          koen.aers

          You should simply make sure they are on the classpath.

          Regards,
          Koen

          • 2. Re: how to specify external jar files for ActionHandlers
            shavianshakes

            I had already added the jars to the classpath ( in Eclipse -> -> Properties -> Java Build Path -> Libraries and "Order and Export"). I hope these are the right places to add. Also they are added to the the $CLASSPATH variable on my linux development system. The build/compile is just fine, but it is at runtime that the error is generated. Do I need to add the jars elsewhere ?

            btw, my JUnit test case which walks the workflow runs just fine.

            I also looked up the code in ProcessClassLoader.java where the error is being generated:

             49 public Class findClass(String name) throws ClassNotFoundException {
             50 Class clazz = null;
             51
             52 FileDefinition fileDefinition = processDefinition.getFileDefinition();
             53 if (fileDefinition!=null) {
             54 String fileName = "classes/" + name.replace( '.', '/' ) + ".class";
             55 byte[] classBytes = fileDefinition.getBytes(fileName);
             56 clazz = defineClass(name, classBytes, 0, classBytes.length);
             57 }
            


            It happens at line 55. Not sure though what to make of it.

            thanks.

            • 3. Re: how to specify external jar files for ActionHandlers
              shavianshakes

              I got it to work by modifying the classpath in the run.sh for starting jboss:

              JBOSS_CLASSPATH="$JBOSS_BOOT_CLASSPATH:/mypath/myjar.jar

              I am sure there is a better way to do this but am unable to find it in the docs.

              thanks.

              • 4. Re: how to specify external jar files for ActionHandlers
                hosierdm

                If you are running the process in JBoss, just stick the jar file in the server//lib directory. I think that should work with a "normal" classloading scheme in JBoss.

                • 5. Re: how to specify external jar files for ActionHandlers
                  koen.aers

                  Yes, this would be the best way if you don't want to modify the webapp. Put the jars in the '%jbpm_server_home%/server/jbpm/lib' folder where '%jbpm_server_home%' is the location where you extracted your starter's kit. Another possibility is to rebuild the webapp and put the jars in the WEB-INF/lib folder of your war file.

                  Regards,
                  Koen