Description of problem: - This is issue is mirrored from the following Community JIRA [1] as it is faced while using BRMS 6.0.1 product libraries too. [1] https://issues.jboss.org/browse/DROOLS-437 Version-Release number of selected component (if applicable): - BRMS 6.0.1 How reproducible: - While trying out the drools-camel-server-example shared in the Community Github project branch [1] and sending a SOAP message to the webservice endpoint the "java.lang.ClassCastException: org.apache.cxf.binding.soap.SoapMessage cannot be cast to java.lang.String" exception takes place . This issue is reproducible in BRMS 6.0.1 too with the help of productised jars from the same release. [1] https://github.com/droolsjbpm/droolsjbpm-integration/tree/6.0.x/drools-camel-server-example Steps to Reproduce: 1. Firstly build the project after downloading it from here [1] and deploy it in BRMS 6.0.1 installation. 2. Then send similar SOAP request messages like these to the webservice endpoint [2] ~~~ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:soap="http://soap.jax.drools.org/">; <soapenv:Header/> <soapenv:Body> <soap:execute> <!--Optional:--> <soap:arg0>hello</soap:arg0> </soap:execute> </soapenv:Body> </soapenv:Envelope> ~~~ 3. Following SOAP fault is received ~~~ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">; <soap:Body> <soap:Fault> <faultcode>soap:Server</faultcode> <faultstring>org.apache.cxf.binding.soap.SoapMessage cannot be cast to java.lang.String</faultstring> </soap:Fault> </soap:Body> </soap:Envelope> ~~~ [1] https://github.com/droolsjbpm/droolsjbpm-integration/tree/6.0.x/drools-camel-server-example [2] http://localhost:8080/drools-camel-server-example-6.0.3-SNAPSHOT/kservice/soap Actual results: - The following exception gets thrown. ~~~ 18:17:41,606 ERROR [org.apache.camel.processor.DefaultErrorHandler] (http-/localhost:8080-2) Failed delivery for (MessageId: ID-vm22-gsslab-pnq-redhat-com-56326-1399546611115-0-7 on ExchangeId: ID-vm22-gsslab-pnq-redhat-com-56326-1399546611115-0-8). Exhausted after delivery attempt: 1 caught: java.lang.ClassCastException: org.apache.cxf.binding.soap.SoapMessage cannot be cast to java.lang.String: java.lang.ClassCastException: org.apache.cxf.binding.soap.SoapMessage cannot be cast to java.lang.String at org.kie.jax.soap.PreCxfTransportSoapProcessor.process(PreCxfTransportSoapProcessor.java:36) [kie-camel-6.0.3-SNAPSHOT.jar:6.0.3-SNAPSHOT] at org.kie.camel.component.KiePolicy$KieProcess.process(KiePolicy.java:323) [kie-camel-6.0.3-SNAPSHOT.jar:6.0.3-SNAPSHOT] at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61) [camel-core-2.10.3.jar:2.10.3] ... at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86) [camel-core-2.10.3.jar:2.10.3] at org.apache.camel.component.cxf.CxfConsumer$1.syncInvoke(CxfConsumer.java:125) [camel-cxf-2.10.3.jar:2.10.3] at org.apache.camel.component.cxf.CxfConsumer$1.invoke(CxfConsumer.java:75) [camel-cxf-2.10.3.jar:2.10.3] at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58) [cxf-bundle-jaxrs-2.6.8.jar:2.6.8] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_51] at java.util.concurrent.FutureTask.run(FutureTask.java:262) [rt.jar:1.7.0_51] at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37) [cxf-bundle-jaxrs-2.6.8.jar:2.6.8] ... 18:17:41,610 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (http-/localhost:8080-2) Application {http://soap.jax.drools.org/}CommandExecutor has thrown exception, unwinding now: org.apache.cxf.interceptor.Fault: org.apache.cxf.binding.soap.SoapMessage cannot be cast to java.lang.String at org.apache.camel.component.cxf.CxfConsumer$1.checkFailure(CxfConsumer.java:200) [camel-cxf-2.10.3.jar:2.10.3] at org.apache.camel.component.cxf.CxfConsumer$1.setResponseBack(CxfConsumer.java:178) [camel-cxf-2.10.3.jar:2.10.3] at org.apache.camel.component.cxf.CxfConsumer$1.syncInvoke(CxfConsumer.java:130) [camel-cxf-2.10.3.jar:2.10.3] at org.apache.camel.component.cxf.CxfConsumer$1.invoke(CxfConsumer.java:75) [camel-cxf-2.10.3.jar:2.10.3] at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58) [cxf-bundle-jaxrs-2.6.8.jar:2.6.8] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_51] at java.util.concurrent.FutureTask.run(FutureTask.java:262) [rt.jar:1.7.0_51] at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37) [cxf-bundle-jaxrs-2.6.8.jar:2.6.8] ... Caused by: java.lang.ClassCastException: org.apache.cxf.binding.soap.SoapMessage cannot be cast to java.lang.String at org.kie.jax.soap.PreCxfTransportSoapProcessor.process(PreCxfTransportSoapProcessor.java:36) [kie-camel-6.0.3-SNAPSHOT.jar:6.0.3-SNAPSHOT] at org.kie.camel.component.KiePolicy$KieProcess.process(KiePolicy.java:323) [kie-camel-6.0.3-SNAPSHOT.jar:6.0.3-SNAPSHOT] at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61) [camel-core-2.10.3.jar:2.10.3] at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.3.jar:2.10.3] ... ~~~ Expected results: - Would have successfully received a SOAP response. Additional info:
Rajesh, Marek, this is coming from a customer and I don't know any work around for it. The fix is a one-line fix limited to the kie-camel jar that integrates Drools with Camel. Requesting the blocker flag in order to include it in 6.0.2. Here is the commit on master: http://github.com/droolsjbpm/droolsjbpm-integration/commit/808eadec0
Cherry-picked into 6.0.x: http://github.com/droolsjbpm/droolsjbpm-integration/commit/a8674ecdb
I tried sending the same SOAP request to drools-camel-server-example as Musharraf described. The CCE is fixed, however now I get a NPE in PostCxfTransportSoapProcessor, see stacktrace: Caused by: java.lang.NullPointerException at java.io.ByteArrayInputStream.<init>(ByteArrayInputStream.java:106) [rt.jar:1.7.0_55] at org.kie.jax.soap.PostCxfTransportSoapProcessor.process(PostCxfTransportSoapProcessor.java:39) [kie-camel-6.0.3-SNAPSHOT.jar:6.0.3-SNAPSHOT] at org.kie.camel.component.KiePolicy$KieProcess.process(KiePolicy.java:328) [kie-camel-6.0.3-SNAPSHOT.jar:6.0.3-SNAPSHOT] It seems that the NPE is a consequence of the fact that the input argument is invalid and it could not be parsed (earlier in the log): com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'H' (code 72) in prolog; expected '<' Please see the attached server.log part for the whole stacktrace. Could you please confirm if the request argument format (the 'hello' string) is valid?
Created attachment 902952 [details] server.log part with the exception
Setting to ASSIGNED, as the NPE should probably be fixed anyway.
The problem happens because the input message is invalid. The server expects an XStream-marshalled command as payload, but the example in this ticket is passing in a simple "hello" string as parameter. An example of valid request is this: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://soap.jax.drools.org/"> <soapenv:Header/> <soapenv:Body> <soap:execute> <soap:arg0> <![CDATA[<batch-execution lookup="ksession1"> <insert out-identifier="message"> <org.drools.server.Message> <text>Helllo World</text> </org.drools.server.Message> </insert> </batch-execution>]]> </soap:arg0> </soap:execute> </soapenv:Body> </soapenv:Envelope> Having said that, I added a couple checks to prevent the NPE at runtime in the kie-camel component: 6.0.x : http://github.com/droolsjbpm/droolsjbpm-integration/commit/96c299cf2 6.1.x : http://github.com/droolsjbpm/droolsjbpm-integration/commit/45d9931bd master : http://github.com/droolsjbpm/droolsjbpm-integration/commit/c3f792397 Even with the above commits, if an invalid request is sent to the end point, xstream will raise an error as it won't be possible to unmarshall the request. Here is a sample response in case of invalid request, like the one in the description of this ticket: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <soap:Fault> <faultcode>soap:Server</faultcode> <faultstring>: Unexpected character 'h' (code 104) in prolog; expected '<' at [row,col {unknown-source}]: [1,1]</faultstring> </soap:Fault> </soap:Body> </soap:Envelope> And the server log will show the following exception: 20:11:27,929 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (http--127.0.0.1-8080-1) Application {http://soap.jax.drools.org/}CommandExecutor has thrown exception, unwinding now: org.apache.cxf.interceptor.Fault: : Unexpected character 'h' (code 104) in prolog; expected '<' at [row,col {unknown-source}]: [1,1]
Verified on BRMS 6.0.2 CR1. The NPE is handled and a valid message produces an expected response.