cancel
Showing results for 
Search instead for 
Did you mean: 

Calls to multiple web service provider fail

eirmag
Champ in-the-making
Champ in-the-making
Hi all,

I would like to achieve a "simple" thing with activiti: call several service providers sequentially. But so far I'm unable to do so! I've created a testcase project to understand exactly what is wrong, with different tests. The test case creates two service provider, deployed in virtually different locations
* A counter service provider, that exposes one method with one parameter. The service is deployed on endpoint http://127.0.0.1:63081/counter
* An echo service provider, that exposes one method with one parameter. The service is deployed on endpoint http://127.0.0.1:63082/echo

Now, the problem I face is "simple" but I'm unable to find the root cause:
Whenever I call a service task from one endpoint, I'm not able to call the other service. For instance, if the first service that I call is the counter service, I'm unable to contact the echo server. The reverse (echo server contacted first -> unable to contact the counter service) produces the same result. The two pictures attached shows the problem in the two cases. I've also attached a listing to present the exception produced when calling the second service provider (does someone knows how to attach txt file to the post? I've put .zip extension, but it is not compressed. I only display partial information to reduce size of the exception inlined). For this file, the scenario is : the business process contacts the Echo server first, then Activiti is unable to contact the Counter server (cannot find the Inc class generated by CXF even though in the 2nd line of the listing, the log says the class is created).

There is attached (in fact no, the project is 3MB large, upload is limited to 256kB. The project can be found at http://nunix.fr/ComplexServiceProblem.zip) a complete eclipse project, that yuo can import. Then run the tests individually or the scenarios, they are unit testing that you can launch with JUnit. The only libraries that you need are CXF (my version is 2.6.1) and the Activiti Designer Extension. I have the sun jdk 1.7.

If you have any idea of what can be wrong, feel free to answer.
Best Regards,

Gabriel

=> Scenario: contact the Echo server first, then Activiti is unable to contact the Counter server (cannot find the Inc class generated by CXF even though in the 2nd line of the listing, the log says the class is created

————————————–
juil. 13, 2012 3:54:16 PM org.apache.cxf.common.jaxb.JAXBUtils logGeneratedClassNames
INFO: Created classes: org.activiti.engine.impl.webservice.Account, org.activiti.engine.impl.webservice.Customer, org.activiti.engine.impl.webservice.Inc, org.activiti.engine.impl.webservice.IncResponse, org.activiti.engine.impl.webservice.IncSimple, org.activiti.engine.impl.webservice.IncSimpleResponse, org.activiti.engine.impl.webservice.ObjectFactory, org.activiti.engine.impl.webservice.TripletObject
warning: [options] bootstrap class path not set in conjunction with -source 1.5
1 warning
juil. 13, 2012 3:54:16 PM org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
WARNING: Interceptor for {http://webservice.impl.engine.activiti.org/}Counter#{http://webservice.impl.engine.activiti.org/}inc has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Marshalling Error: org.activiti.engine.impl.webservice.Inc is not known to this context
   at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:261)
   at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:169)
   ……
   ……
   ……
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.SAXException2: org.activiti.engine.impl.webservice.Inc is not known to this context
javax.xml.bind.JAXBException: org.activiti.engine.impl.webservice.Inc is not known to this context]
   at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:326)
   at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:251)
   at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:95)
   at org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:554)
   at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:236)
   … 134 more
Caused by: com.sun.istack.SAXException2: org.activiti.engine.impl.webservice.Inc is not known to this context
javax.xml.bind.JAXBException: org.activiti.engine.impl.webservice.Inc is not known to this context
   at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:247)
   at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:262)
   at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:148)
   at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:131)
   at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:333)
   at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:340)
   at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:76)
   at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494)
   at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323)
   … 138 more
Caused by: javax.xml.bind.JAXBException: org.activiti.engine.impl.webservice.Inc is not known to this context
   at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:619)
   at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:145)
   … 144 more

juil. 13, 2012 3:54:16 PM org.activiti.engine.impl.webservice.WSOperation safeSend
WARNING: Error calling WS http://webservice.activiti.org/:Counter
org.apache.cxf.interceptor.Fault: Marshalling Error: org.activiti.engine.impl.webservice.Inc is not known to this context
   at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:261)
   at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:169)
   at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:110)
   at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)
   at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
   at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:532)
   ……
   ……
   ……
   ……
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.SAXException2: org.activiti.engine.impl.webservice.Inc is not known to this context
javax.xml.bind.JAXBException: org.activiti.engine.impl.webservice.Inc is not known to this context]
   at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:326)
   at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:251)
   at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:95)
   at org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:554)
   at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:236)
   … 134 more
Caused by: com.sun.istack.SAXException2: org.activiti.engine.impl.webservice.Inc is not known to this context
javax.xml.bind.JAXBException: org.activiti.engine.impl.webservice.Inc is not known to this context
   at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:247)
   at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:262)
   at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:148)
   at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:131)
   at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:333)
   at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:340)
   at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:76)
   at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494)
   at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323)
   … 138 more
Caused by: javax.xml.bind.JAXBException: org.activiti.engine.impl.webservice.Inc is not known to this context
   at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:619)
   at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:145)
   … 144 more
2 REPLIES 2

frederikherema1
Star Contributor
Star Contributor
Looks more like a CXF/JAXB-issue… My guess: When one web service is created, the JAXB-context is initialized  by cxf, only containing that service-objects mapping. When the second call is done, the existing JAXB-context is used, not containing the second service and it's referenced/used beans.

org.apache.cxf.interceptor.Fault: Marshalling Error: org.activiti.engine.impl.webservice.Inc is not known to this context
Double check you're configuring CXF correctly

eirmag
Champ in-the-making
Champ in-the-making
Yes, it's totally true. I've run a couple of test in addition to isolate the problem, and it definitelly seems to come from JAXB context issues when CXF is consuming several services *sharing data types*.

I've explained one part of the problem related to CXF in http://cxf.547215.n5.nabble.com/Calls-to-multiple-web-service-provider-within-Activiti-fail-with-a-M..., but I post here additional info on how I've resolved the problem within activiti, because even after having resolved the "package" conflict, activiti is still unable to call multiple services that share the same object definition (the data types, with same namespace, name, contract that are used in different services located in different administrative domains).

In such case, the problem comes from the WSDL definition generated by CXF. It puts the data type with the namespare relative to the service being consumed. It means that for a CounterService located in "org.nunix.webservice.counter" namespace (cf Picture attached), the data types described in the WSDL belongs to this namespace. But when consuming resources, the actual package of the data type objects is "org.nunix.webservice" (as it is shared by several services, i've put them a package upper). Therefore, activiti tries to retrieve classes like "org.nunix.webservice.counter.TripletObject" with no success, and miserably fails with:

juil. 20, 2012 10:51:39 AM org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
WARNING: Interceptor for {org.nunix.webservice.counter.CounterService}CounterService#{http://counter.webservice.nunix.org/}inc has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: org.nunix.webservice.TripletObject cannot be cast to org.nunix.webservice.counter.TripletObject
at org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor.handleMessage(WrapperClassOutInterceptor.java:121)
…..
I've tried several approaches with no success
* modify the wsdl to have the data types with correct namespace, such as it resolves to "org.nunix.webservice"
* have data type objects in packages both counter and echo packages. But it also fail as, by generating classes, activiti was in front of several classes with the same jaxb name (one class in counter package, the other in echo package, but also the generated ones)
* probably other that I don't remember

So what I did, is follow instructions found in http://www.bpm-guide.de/2010/12/09/how-to-call-a-webservice-from-bpmn/ where we prevent activiti to wrap itself the call to cxf, and perform our own web service invocation using a java service delegate. Within this delegate, I simply use the JAX-WS proxy client way to consume services, taking parameters from activiti variables, and exporting return values in other variables. It is not what I intended to do in the first place, as there is a additional overhead when creating new services, and I wanted to have everything described in the activiti bpmn, but it works so far.

As last word, let me know if it's possible to have an "elegant" option to consume services with my constraints within Activiti without relying on external service task delegate.