8 Replies Latest reply on Jul 17, 2010 12:57 PM by shawnhnguyen

    Consuming webservice in jBPM JPDL (Eclipse)

    chrlyck

      Hi guys

      Starting to get better at this stuff - i have a really annoying problem with consuming webservices in jBPM though.

      Until now i have been making processes calling internal stuff, and using a lot of examples.

      My first step into the real world is consuming a webservice.

      I made the webservice myself, its a simple java webservice adding two numbers together. I have tested it by implementing a client in NetBeans IDE 6.1, and it works like a charm. I have copied the code to jBPM and made a simple process executing it.

      To make things even more simple i have put the webservices code in the same package as the client itself, i was unsure whether it actually deployed the files...

      Here it is:

      package com.sample.action;
      
      import org.apache.commons.logging.Log;
      import org.apache.commons.logging.LogFactory;
      import org.jbpm.graph.def.ActionHandler;
      import org.jbpm.graph.exe.ExecutionContext;
      
      public class isbncheck implements ActionHandler {
      
       private static final long serialVersionUID = 1L;
      
       public void execute(ExecutionContext executionContext) throws Exception
       {
       String msg;
       try
       {
       log.info("##############################");
       log.info("Debug:1");
       CalculatorWSService service = new CalculatorWSService();
       log.info("Debug:2");
       CalculatorWS port = service.getCalculatorWSPort(); //TODO: Error - wtf?
       log.info("Debug:3");
       int i = 3;
       int j = 400000;
       int result = port.add(i, j);
       msg = "Result = "+result;
       }
       catch (Exception ex)
       {
       msg = "Error: " + ex.getMessage();
       }
       log.info(msg);
       log.info("##############################");
       executionContext.leaveNode();
       }
      
       private static final Log log = LogFactory.getLog(isbncheck.class);
      }


      When running this, my webserver (tomcat 6) sends the following output.

      09:42:45,912 INFO [isbncheck] ##############################
      09:42:45,912 INFO [isbncheck] Debug:1
      09:42:45,943 INFO [isbncheck] Debug:2
      09:42:45,975 INFO [isbncheck] Error: Cannot load service endpoint interface: com.sample.action.CalculatorWS
      09:42:45,975 INFO [isbncheck] ##############################


      As you might have guessed by the name of the class i have tried with another webservice with the same error (an ISBN check webservice). In both cases i can create the service, but when calling the service.get*Whatever*Port() i get the error. I've been googling like a mad-man but nobody seems to have this problem, so what am i doing wrong?

      Btw. i'm sure it's a simple question, but how do i do the "printstacktrace" to the webserver console so i can see the full error?

      Thanks in advance.

      Nibe

        • 1. Re: Consuming webservice in jBPM JPDL (Eclipse)
          chrlyck

          I deployed using the deployment tab in jBPM JPDL and marked the src/main/java so everything should be ok, but am i supposed to put the com.sample.action.CalculatorWS-stuff somewhere in a jar-file so it's in the classpath?

          I made a jar and put it in the lib-folder, but no luck. Got the printstacktrace to work - don't know what happened since it didn't work - not much help looking at it though.

          10:31:50,271 ERROR [STDERR] org.jboss.ws.WSException: Cannot load service endpoint interface: com.sample.action.CalculatorWS
          10:31:50,271 ERROR [STDERR] at org.jboss.ws.metadata.umdm.EndpointMetaData.getServiceEndpointInterface(EndpointMetaData.java:248)
          10:31:50,271 ERROR [STDERR] at org.jboss.ws.metadata.umdm.EndpointMetaData.eagerInitializeOperations(EndpointMetaData.java:525)
          10:31:50,271 ERROR [STDERR] at org.jboss.ws.metadata.umdm.EndpointMetaData.initializeInternal(EndpointMetaData.java:519)
          10:31:50,271 ERROR [STDERR] at org.jboss.ws.metadata.umdm.EndpointMetaData.eagerInitialize(EndpointMetaData.java:507)
          10:31:50,271 ERROR [STDERR] at org.jboss.ws.metadata.builder.jaxws.JAXWSClientMetaDataBuilder.rebuildEndpointMetaData(JAXWSClientMetaDat
          aBuilder.java:308)
          10:31:50,271 ERROR [STDERR] at org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.getPortInternal(ServiceDelegateImpl.java:262)
          10:31:50,271 ERROR [STDERR] at org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.getPort(ServiceDelegateImpl.java:193)
          10:31:50,271 ERROR [STDERR] at javax.xml.ws.Service.getPort(Service.java:92)
          10:31:50,271 ERROR [STDERR] at com.sample.action.CalculatorWSService.getCalculatorWSPort(CalculatorWSService.java:57)
          10:31:50,271 ERROR [STDERR] at com.sample.action.isbncheck.execute(isbncheck.java:21)
          10:31:50,271 ERROR [STDERR] at org.jbpm.graph.def.Action.execute(Action.java:122)
          10:31:50,271 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          10:31:50,271 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          10:31:50,271 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          10:31:50,271 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
          10:31:50,271 ERROR [STDERR] at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:173)
          10:31:50,271 ERROR [STDERR] at org.jbpm.graph.def.Action_$$_javassist_34.execute(Action_$$_javassist_34.java)
          10:31:50,271 ERROR [STDERR] at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:259)
          10:31:50,271 ERROR [STDERR] at org.jbpm.graph.def.Node.execute(Node.java:338)
          10:31:50,271 ERROR [STDERR] at org.jbpm.graph.def.Node.enter(Node.java:318)
          10:31:50,271 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          10:31:50,271 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          10:31:50,271 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          10:31:50,271 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
          10:31:50,271 ERROR [STDERR] at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:173)
          10:31:50,271 ERROR [STDERR] at org.jbpm.graph.def.Node_$$_javassist_80.enter(Node_$$_javassist_80.java)
          10:31:50,271 ERROR [STDERR] at org.jbpm.graph.def.Transition.take(Transition.java:151)
          10:31:50,271 ERROR [STDERR] at org.jbpm.graph.def.Node.leave(Node.java:393)
          10:31:50,271 ERROR [STDERR] at org.jbpm.graph.node.StartState.leave(StartState.java:70)
          10:31:50,271 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          10:31:50,271 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          10:31:50,271 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          10:31:50,271 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
          10:31:50,271 ERROR [STDERR] at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:173)
          10:31:50,271 ERROR [STDERR] at org.jbpm.graph.def.Node_$$_javassist_80.leave(Node_$$_javassist_80.java)
          10:31:50,271 ERROR [STDERR] at org.jbpm.graph.exe.Token.signal(Token.java:192)
          10:31:50,271 ERROR [STDERR] at org.jbpm.graph.exe.Token.signal(Token.java:163)
          10:31:50,271 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          10:31:50,271 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          10:31:50,271 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          10:31:50,271 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
          10:31:50,271 ERROR [STDERR] at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:173)
          10:31:50,271 ERROR [STDERR] at org.jbpm.graph.exe.Token_$$_javassist_14.signal(Token_$$_javassist_14.java)
          10:31:50,271 ERROR [STDERR] at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:482)
          10:31:50,287 ERROR [STDERR] at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:421)
          10:31:50,287 ERROR [STDERR] at org.jbpm.jsf.core.action.CompleteTaskActionListener.handleAction(CompleteTaskActionListener.java:52)
          10:31:50,287 ERROR [STDERR] at org.jbpm.jsf.core.impl.JbpmActionListenerWrapper.processAction(JbpmActionListenerWrapper.java:82)
          10:31:50,287 ERROR [STDERR] at javax.faces.event.ActionEvent.processListener(ActionEvent.java:77)
          10:31:50,287 ERROR [STDERR] at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:746)
          10:31:50,287 ERROR [STDERR] at javax.faces.component.UICommand.broadcast(UICommand.java:368)
          10:31:50,287 ERROR [STDERR] at org.jbpm.jsf.taskform.ui.UITaskFormButtonBase.broadcast(UITaskFormButtonBase.java:56)
          10:31:50,287 ERROR [STDERR] at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:447)
          10:31:50,287 ERROR [STDERR] at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
          10:31:50,287 ERROR [STDERR] at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
          10:31:50,287 ERROR [STDERR] at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
          10:31:50,287 ERROR [STDERR] at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
          10:31:50,287 ERROR [STDERR] at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
          10:31:50,287 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
          10:31:50,287 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          10:31:50,287 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
          10:31:50,287 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          10:31:50,287 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          10:31:50,287 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
          10:31:50,287 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
          10:31:50,287 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
          10:31:50,287 ERROR [STDERR] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
          10:31:50,287 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
          10:31:50,287 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
          10:31:50,287 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
          10:31:50,287 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
          10:31:50,287 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
          10:31:50,287 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
          10:31:50,287 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
          10:31:50,287 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
          10:31:50,287 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
          10:31:50,287 ERROR [STDERR] at java.lang.Thread.run(Thread.java:619)
          10:31:50,287 ERROR [STDERR] Caused by: java.lang.ClassNotFoundException: com.sample.action.CalculatorWS
          10:31:50,287 ERROR [STDERR] at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
          10:31:50,287 ERROR [STDERR] at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
          10:31:50,287 ERROR [STDERR] at org.jboss.ws.metadata.umdm.EndpointMetaData.getServiceEndpointInterface(EndpointMetaData.java:239)
          10:31:50,287 ERROR [STDERR] ... 75 more


          • 2. Re: Consuming webservice in jBPM JPDL (Eclipse)
            kukeltje

             

            I deployed using the deployment tab in jBPM JPDL and marked the src/main/java so everything should be ok, but am i supposed to put the com.sample.action.CalculatorWS-stuff somewhere in a jar-file so it's in the classpath?


            Yes, but probably everything. The ws libs probably cannot access the processclassloader, so put *everything* in a jar on the classpath. Does it work then? You loose class versioning though, but I've never used that very much.

            • 3. Re: Consuming webservice in jBPM JPDL (Eclipse)
              chrlyck

              Hi again

              Thanks for the reply.

              I have been looking into this thoroughly. I have tried two things, my original setup where i deploy the WS jars using JPDL, then not deploying them. Then the same two options with the custom-made jar in the classpath. Here are my results:

              Webservice NOT deployed from JDPL deployed - without JAR

              exception
              
              javax.servlet.ServletException: Servlet execution threw an exception
               org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              
              
              root cause
              
              java.lang.NoClassDefFoundError: org/me/calculator/CalculatorWSService
               java.lang.Class.getDeclaredConstructors0(Native Method)
               java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
               java.lang.Class.getConstructor0(Class.java:2671)


              Webservice deployed from JDPL - without JAR

              Error: Cannot load service endpoint interface: com.sample.action.CalculatorWS


              Webservice NOT deployed from JDPL - with JAR

              exception
              
              javax.servlet.ServletException: Servlet execution threw an exception
               org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              
              
              root cause
              
              java.lang.NoClassDefFoundError: javax/xml/ws/Service
               java.lang.ClassLoader.defineClass1(Native Method)
               java.lang.ClassLoader.defineClass(ClassLoader.java:620


              Webservice deployed from JDPL - with JAR

              exception
              
              javax.servlet.ServletException: Servlet execution threw an exception
               org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              
              
              root cause
              
              java.lang.NoClassDefFoundError: javax/xml/ws/Service
               java.lang.ClassLoader.defineClass1(Native Method)
               java.lang.ClassLoader.defineClass(ClassLoader.java:620


              So it seems like thats not the solution...

              Any other ideas?

              • 4. Re: Consuming webservice in jBPM JPDL (Eclipse)
                chrlyck

                Sorry for the confusion in the above post - in my debugging i have now moved the ws to org.me.calculator. So 2nd error in the previous post is actually the following.

                Error: Cannot load service endpoint interface: org.me.calculator.CalculatorWS


                • 5. Re: Consuming webservice in jBPM JPDL (Eclipse)
                  kukeltje

                  What if you put *everyting* related to your webservice outside the jbpm war. It definately is a classloader issue. Can you e.g. in tree format specify what

                  Webservice deployed from JDPL - with JAR
                  means.

                  e.g.
                  deploy/
                   jbpm.war/
                   libs/
                   jaxws.jar
                   jbpm.jar
                  
                  
                  jpdl.par/
                   processdefinition.xml
                   classes/
                   ....
                  
                  etc
                  


                  That is much clearer. Remember... jar files in processarchives do not work

                  • 6. Re: Consuming webservice in jBPM JPDL (Eclipse)
                    chrlyck

                    Thanks again, i think we are getting somewhere... :)

                    OK, here goes. I have tried two methods. As mentioned i deploy using JPDL so i don't really know what my .par is named and what happens to it, but it shouldn't matter...

                    ?.par
                    -first.xhtml
                    -forms.xml
                    -gpd.xml
                    -processdefinition.xml
                    -processimage.xml
                    -clh.java (package)
                    --calc.java
                    -org.me.calculator (package)
                    --Add.java
                    --AddResponse.java
                    --CalculatorWS.java
                    --CalculatorWSService.java
                    --MessageActionHandler.java
                    --ObjectFactory.java
                    --package-info.java

                    I built a jax.war (zipped the mentioned files below and renamed to war). Then put it in the "jbpm-jpdl-3.2.3\deploy" dir.

                    deploy
                    -jax.war
                    --activation.jar
                    --jaxb1-impl.jar
                    --jaxb-api.jar
                    --jaxb-impl.jar
                    --jax-xjc.jar
                    --jboss-jaxws.jar
                    --jse173_1.0_api.jar

                    This results in the err

                    Cannot load service endpoint interface: org.me.calculator.CalculatorWS


                    Right after "Debug:2". This is printed in the web-server but the webinterface returns

                    Information
                    Variables updated
                    Task completed


                    So i think this is close...

                    If i remove my .war file i get the exact same result so you must be right is a classloader issue...

                    Looking for the right solution since i don't know if i did my .war correctly i have tried putting all the JAR-files in the classpath (edited the run.bat so it imports them)

                    So my startup of the jboss server says:

                    ===============================================================================

                    JBoss Bootstrap Environment

                    JBOSS_HOME: C:\Program Files\jBPM\jbpm-jpdl-3.2.3\server

                    JAVA: C:\Program Files\Java\jdk1.5.0_16\bin\java

                    JAVA_OPTS: -Dprogram.name=run.bat -server -Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.g
                    cInterval=3600000

                    CLASSPATH: C:\Program Files\jBPM\jbpm-jpdl-3.2.3\server\CP\activation.jar;C:\Program Files\jBPM\jbpm-jpdl-3.2.3\server\CP\j
                    axb1-impl.jar;C:\Program Files\jBPM\jbpm-jpdl-3.2.3\server\CP\jaxb-api.jar;C:\Program Files\jBPM\jbpm-jpdl-3.2.3\server\CP\ja
                    xb-impl.jar;C:\Program Files\jBPM\jbpm-jpdl-3.2.3\server\CP\jaxb-xjc.jar;C:\Program Files\jBPM\jbpm-jpdl-3.2.3\server\CP\jbos
                    s-jaxws.jar;C:\Program Files\jBPM\jbpm-jpdl-3.2.3\server\CP\jsr173_1.0_api.jar;C:\Program Files\Java\jdk1.5.0_16\lib\tools.ja
                    r;C:\Program Files\jBPM\jbpm-jpdl-3.2.3\server\bin\run.jar

                    ===============================================================================


                    This returns an error in the webinterface:

                    description The server encountered an internal error () that prevented it from fulfilling this request.

                    exception

                    javax.servlet.ServletException: Servlet execution threw an exception
                    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


                    root cause

                    java.lang.NoClassDefFoundError: javax/xml/soap/FactoryLoader
                    javax.xml.ws.spi.Provider.provider(Provider.java:91)
                    javax.xml.ws.Service.<init>(Service.java:83)
                    org.me.calculator.CalculatorWSService.<init>(CalculatorWSService.java:47)
                    clh.java.calc.execute(calc.java:22)


                    So with the first example i get to line 24 of my code (Debug:2) in the 2nd i get to line 22 which is where i create the service... See below:

                    log.info("##############################");
                    log.info("Debug:1");
                    CalculatorWSService service = new CalculatorWSService(); //line 22
                    log.info("Debug:2");
                    CalculatorWS port = service.getCalculatorWSPort(); //line 24
                    log.info("Debug:3");


                    • 7. Re: Consuming webservice in jBPM JPDL (Eclipse)
                      kukeltje

                      the jaxws.war cannot load things from the processarchive (via the processclassloader) so that is an expected error.

                      with 'everything' I just meant the classes that are in the processarchive, not all the jaxb stuff etc... (that should already be on the classpath by jboss itself. Adding them to the classpath manually can give you many errors

                      • 8. Re: Consuming webservice in jBPM JPDL (Eclipse)
                        shawnhnguyen

                        Have you got this to work?  I've the same exact problem here and can't seem to figure out how to deploy my process either.  I've been googling like mad as well, but only keeps coming back to this thread.  I've tried to decipher what you've done here and for the most part am understanding the process you go through.  Unfortunately the way my work has deployed jbpm inside of jboss I have a very difficult time understanding where all the locations of dependent files goes.  I haven't deployed to the classpath as suggested here but did it work for you?  from what I can see here it did not.  Thanks for any help.