4 Replies Latest reply on Jun 18, 2010 5:17 AM by HuiSheng Xu

    Invoking web service from an ExternalActivityBehaviour

    Stephane Malbequi Newbie

      Hi,

       

      I have a class loading problem when I try to consume a web service from an ExternalActivityBehaviour.

       

      I will try to explain :

       

      1 I have generated a web service client with the jaxws maven plugin

       

      2 I have tested it with a JUnit test : it's ok

       

      3 I have created a process and have used the same code as the unit test in an ExternalActivityBehaviour in order to consume the web service

       

      4 I have packaged the process in a bar file and deployed it with an ant build file. The bar file contains the jpdl  files, the ExternalActivityBehaviour class and all jaxws generated classes.

       

      5 When the process starts and enter in the custom node, I obtain "Cannot load service endpoint interface" because "ClassNotFoundException" (the generated client interface in fact)

       

      If I have understood, the classloader (the same used by the SOAP stack) can't find the classes of my bar file.

       

      I read some posts that say : with jbpm3 we have to add java source files in the process archive. So I have tested and packaged a new bar file with the .java files near .class files, but same result.

       

      So my question is : How to consume a web service from an ExternalActivityBehaviour with the generated client classes all packaged in a bar file.

       

      I have no war file, just a bar file to deploy. I hope I haven't to put all generated classes in a jar and in a jboss lib directory.

       

      Thanks in advance.

       

      Stéphane.

       

      jBPM 4.3, JBoss 4.2.1.GA

        • 1. Re: Invoking web service from an ExternalActivityBehaviour
          HuiSheng Xu Master

          Hi Stephane,

           

          Do you mean that when you run a process and in a acitivity, it will use a webservice to do some request. But jaxws cannot find the webservice interface class?

           

          Because you packed externalActivityBehaviour and ws classes into .bar,  when the process ran,  jbpm4 will load these classes from database.  At this time, jbpm4 will use a specified classloader to find these classes.  And seems jaxws cannot find these classes,  so I guess jaxws didn't know the jbpm4's classloader exists.

           

          I don't know much about jaxws,  If it could re-use threadContextClassLoader to find related classes,  we could re-configure current thread contextClassLoader in the externalActivityBehaviour.  like this:

           

          ClassLoader original = Thread.currentThread().getContextClassLoader();
          try {
            Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
            // do ws
          } finally {
            Thread.currentThread().setContextClassLoader(original);
          }
          

           

          But if jaxws couldnot re-use contextClassLoader, I am afraid you should find a way to let jaxws access the jbpm4 deployclassloader to achieve that.

           

          And Good Luck.

          1 of 1 people found this helpful
          • 2. Re: Invoking web service from an ExternalActivityBehaviour
            Sebastian Schneider Master

            In the jBPM 3.2 there is a configuration property to set the classloader. While running in quite a similar issue I managed to solve it by setting:

             

            <string name="jbpm.class.loader" value="context" />

             

            in jbpm.cfg.xml.

            • 3. Re: Invoking web service from an ExternalActivityBehaviour
              Stephane Malbequi Newbie

              Thanks a lot HuiSheng, it works like a charm!

              • 4. Re: Invoking web service from an ExternalActivityBehaviour
                HuiSheng Xu Master

                Hi Sebastain,

                 

                I searched jbpm3 sources, and find this property is used in the org.jbpm.util.ClassLoaderUtil.java.  It is used to decide which classLoade you will use, the class loaded jbpm or the current thread context class loader.  It won't chane the current thread context loader,  So event if we add this feature in jbpm4, it won't help to solve this problem.