2011-06-10 99 views
1

我一直在試圖讓兩個單獨的包通過使用駱駝cxf生產者的nmr端點進行通信。我整個星期都在研究這個問題,到目前爲止我無法完成這項工作。servicemix 4.3.2駱駝cxf生產者到cxf-nmr消費者不工作

但是我可以像所有示例cxf-camel-nmr中的nmr端點一樣沒有問題,所以我知道這個bundle是可以的。說真的,這是一個超級簡單的Hello World世界原型,我無法得到它的工作。

任何幫助或建議將是真棒!

ENV:爪哇1.5 的Apache ServiceMix的4.3.2(處女安裝)

在ServiceMix的我有兩個單獨的OSGi包。我無法讓我的駱駝cxf生產者成功調用nmr端點,並且無法解決如何解決問題。

包#1的cxf-NMR //消費者

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:jaxws="http://cxf.apache.org/jaxws" 
    xsi:schemaLocation=" 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> 

    <import resource="classpath:META-INF/cxf/cxf.xml" /> 
    <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /> 
    <import resource="classpath:META-INF/cxf/transport/nmr/cxf-transport-nmr.xml" /> 

    <jaxws:endpoint id="helloWorld1" 
        implementor="org.apache.servicemix.examples.cxf.HelloWorldImpl" 
        address="nmr:HelloWorld1" /> 

</beans> 

包#2 //生產者

<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:osgi="http://www.springframework.org/schema/osgi" 
     xmlns:camel="http://camel.apache.org/schema/spring" 
     xmlns:cxf="http://camel.apache.org/schema/cxf" 

     xsi:schemaLocation=" 
     http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd 
     http://servicemix.apache.org/http/1.0 http://servicemix.apache.org/http/1.0/servicemix-http.xsd 
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd 
     http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd 
     http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> 

    <import resource="classpath:META-INF/cxf/cxf.xml" /> 
    <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /> 
    <import resource="classpath:META-INF/cxf/transport/nmr/cxf-transport-nmr.xml" /> 
    <import resource="classpath:org/apache/servicemix/camel/nmr/camel-nmr.xml" /> 
    <import resource="classpath:META-INF/cxf/cxf-extension-http.xml"/> 

    <import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml" /> 

    <camel:camelContext xmlns="http://camel.apache.org/schema/spring"> 
    <route> 
     <from uri="cxf:bean:testEndpoint"/> 
     <to uri="nmr:HelloWorld1"/> 
    </route> 
</camel:camelContext> 
    <cxf:cxfEndpoint 
     id="testEndpoint" 
     address="http://localhost:9090/test" 
     serviceClass="org.apache.servicemix.examples.cxf.HelloWorld"> 
     <cxf:properties> 
      <entry key="dataFormat" value="PAYLOAD" /> 
     </cxf:properties> 
    </cxf:cxfEndpoint> 
</beans> 

-

################# 
soap request response 
################# 
<?xml version="1.0"?> 
<SOAP-ENV:Envelope 
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
    SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 
    <SOAP-ENV:Body> 
     <m:sayHi xmlns:m="http://cxf.examples.servicemix.apache.org/"> 
     <arg0>foobar</arg0> 
     </m:sayHi> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

STATUS: 500 
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>java.lang.NullPointerException</faultstring></soap:Fault></soap:Body></soap:Envelope> 

-

#################### 
Console Output - No Idea How To Fix 
#################### 

18:56:04,544 | ERROR | oWorld1-thread-1 | NMRDestination     | - - | error preparing message 
java.lang.NullPointerException 
    at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1183)[116:org.apache.cxf.bundle:2.3.2] 
    at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:427)[116:org.apache.cxf.bundle:2.3.2] 
    at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:380)[116:org.apache.cxf.bundle:2.3.2] 
    at org.apache.servicemix.cxf.transport.nmr.NMRMessageHelper.convertMessageToInputStream(NMRMessageHelper.java:43)[203:org.apache.servicemix.cxf.transport.nmr:4.3.0] 
    at org.apache.servicemix.cxf.transport.nmr.NMRDestination.process(NMRDestination.java:127)[203:org.apache.servicemix.cxf.transport.nmr:4.3.0] 
    at org.apache.servicemix.nmr.core.InternalEndpointWrapper.process(InternalEndpointWrapper.java:86)[83:org.apache.servicemix.nmr.core:1.4.0] 
    at org.apache.servicemix.nmr.core.ChannelImpl.process(ChannelImpl.java:255)[83:org.apache.servicemix.nmr.core:1.4.0] 
    at org.apache.servicemix.nmr.core.ChannelImpl$1.run(ChannelImpl.java:215)[83:org.apache.servicemix.nmr.core:1.4.0] 
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651)[:1.5.0_22] 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676)[:1.5.0_22] 
    at java.lang.Thread.run(Thread.java:595)[:1.5.0_22] 
18:56:04,547 | WARN | oWorld1-thread-1 | NMR        | 83 - org.apache.servicemix.nmr.core - 1.4.0 | Error processing exchange [ 
    id:  a778d16c-2955-41de-89e8-7775f4f976bf 
    mep:  InOut 
    status: Active 
    role:  Provider 
    target: PropertyMatchingReference[{NAME=HelloWorld1}] 
    properties: [ 
     jaxwsContext = {javax.xml.ws.wsdl.operation={http://cxf.examples.servicemix.apache.org/}sayHi, javax.xml.ws.wsdl.description=http://localhost:9090/test?wsdl, javax.xml.ws.wsdl.service={http://cxf.examples.servicemix.apache.org/}HelloWorldService, javax.xml.ws.wsdl.interface={http://cxf.examples.servicemix.apache.org/}HelloWorld, javax.xml.ws.wsdl.port={http://cxf.examples.servicemix.apache.org/}HelloWorldPort} 
     CamelToEndpoint = nmr://HelloWorld1 
     org.apache.cxf.service.model.BindingOperationInfo = [BindingOperationInfo: {http://cxf.examples.servicemix.apache.org/}sayHi] 
     mtom-enabled = false 
     CamelCreatedTimestamp = Thu Jun 09 18:56:04 PDT 2011 
     CamelCXFDataFormat = PAYLOAD 
    ] 
] 

org.apache.servicemix.nmr.api.ServiceMixException: java.lang.NullPointerException 
    at org.apache.servicemix.cxf.transport.nmr.NMRDestination.process(NMRDestination.java:151)[203:org.apache.servicemix.cxf.transport.nmr:4.3.0] 
    at org.apache.servicemix.nmr.core.InternalEndpointWrapper.process(InternalEndpointWrapper.java:86)[83:org.apache.servicemix.nmr.core:1.4.0] 
    at org.apache.servicemix.nmr.core.ChannelImpl.process(ChannelImpl.java:255)[83:org.apache.servicemix.nmr.core:1.4.0] 
    at org.apache.servicemix.nmr.core.ChannelImpl$1.run(ChannelImpl.java:215)[83:org.apache.servicemix.nmr.core:1.4.0] 
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651)[:1.5.0_22] 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676)[:1.5.0_22] 
    at java.lang.Thread.run(Thread.java:595)[:1.5.0_22] 
Caused by: java.lang.NullPointerException 
    at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1183)[116:org.apache.cxf.bundle:2.3.2] 
    at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:427)[116:org.apache.cxf.bundle:2.3.2] 
    at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:380)[116:org.apache.cxf.bundle:2.3.2] 
    at org.apache.servicemix.cxf.transport.nmr.NMRMessageHelper.convertMessageToInputStream(NMRMessageHelper.java:43)[203:org.apache.servicemix.cxf.transport.nmr:4.3.0] 
    at org.apache.servicemix.cxf.transport.nmr.NMRDestination.process(NMRDestination.java:127)[203:org.apache.servicemix.cxf.transport.nmr:4.3.0] 
    ... 6 more 
18:56:04,552 | ERROR | f2d4607-thread-1 | DefaultErrorHandler    | 68 - org.apache.camel.camel-core - 2.6.0 | Failed delivery for exchangeId: ID-Dana-PC-45880-1307670949817-0-2. Exhausted after delivery attempt: 1 caught: org.apache.servicemix.nmr.api.ServiceMixException: java.lang.NullPointerException 
org.apache.servicemix.nmr.api.ServiceMixException: java.lang.NullPointerException 
    at org.apache.servicemix.cxf.transport.nmr.NMRDestination.process(NMRDestination.java:151)[203:org.apache.servicemix.cxf.transport.nmr:4.3.0] 
    at org.apache.servicemix.nmr.core.InternalEndpointWrapper.process(InternalEndpointWrapper.java:86)[83:org.apache.servicemix.nmr.core:1.4.0] 
    at org.apache.servicemix.nmr.core.ChannelImpl.process(ChannelImpl.java:255)[83:org.apache.servicemix.nmr.core:1.4.0] 
    at org.apache.servicemix.nmr.core.ChannelImpl$1.run(ChannelImpl.java:215)[83:org.apache.servicemix.nmr.core:1.4.0] 
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651)[:1.5.0_22] 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676)[:1.5.0_22] 
    at java.lang.Thread.run(Thread.java:595)[:1.5.0_22] 
Caused by: java.lang.NullPointerException 
    at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1183)[116:org.apache.cxf.bundle:2.3.2] 
    at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:427)[116:org.apache.cxf.bundle:2.3.2] 
    at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:380)[116:org.apache.cxf.bundle:2.3.2] 
    at org.apache.servicemix.cxf.transport.nmr.NMRMessageHelper.convertMessageToInputStream(NMRMessageHelper.java:43)[203:org.apache.servicemix.cxf.transport.nmr:4.3.0] 
    at org.apache.servicemix.cxf.transport.nmr.NMRDestination.process(NMRDestination.java:127)[203:org.apache.servicemix.cxf.transport.nmr:4.3.0] 
    ... 6 more 
18:56:04,553 | WARN | qtp407691725-242 | PhaseInterceptorChain   | - - | Interceptor for {http://cxf.examples.servicemix.apache.org/}HelloWorldService#{http://cxf.examples.servicemix.apache.org/}sayHi has thrown exception, unwinding now 
org.apache.cxf.interceptor.Fault: java.lang.NullPointerException 
    at org.apache.camel.component.cxf.CxfConsumer$1.checkFailure(CxfConsumer.java:219)[118:org.apache.camel.camel-cxf:2.6.0] 
    at org.apache.camel.component.cxf.CxfConsumer$1.setResponseBack(CxfConsumer.java:196)[118:org.apache.camel.camel-cxf:2.6.0] 
    at org.apache.camel.component.cxf.CxfConsumer$1.asyncInvoke(CxfConsumer.java:116)[118:org.apache.camel.camel-cxf:2.6.0] 
    at org.apache.camel.component.cxf.CxfConsumer$1.invoke(CxfConsumer.java:73)[118:org.apache.camel.camel-cxf:2.6.0] 
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)[116:org.apache.cxf.bundle:2.3.2] 
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:93)[116:org.apache.cxf.bundle:2.3.2] 
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:255)[116:org.apache.cxf.bundle:2.3.2] 
    at org.apache.cxf.phase.PhaseInterceptorChain.resume(PhaseInterceptorChain.java:224)[116:org.apache.cxf.bundle:2.3.2] 
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:70)[116:org.apache.cxf.bundle:2.3.2] 
    at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:311)[116:org.apache.cxf.bundle:2.3.2] 
    at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:280)[116:org.apache.cxf.bundle:2.3.2] 
    at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:72)[116:org.apache.cxf.bundle:2.3.2] 
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:931)[149:org.eclipse.jetty.server:7.2.2.v20101205] 
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:868)[149:org.eclipse.jetty.server:7.2.2.v20101205] 
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)[149:org.eclipse.jetty.server:7.2.2.v20101205] 
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:185)[149:org.eclipse.jetty.server:7.2.2.v20101205] 
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:114)[149:org.eclipse.jetty.server:7.2.2.v20101205] 
    at org.eclipse.jetty.server.Server.handleAsync(Server.java:397)[149:org.eclipse.jetty.server:7.2.2.v20101205] 
    at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:601)[149:org.eclipse.jetty.server:7.2.2.v20101205] 
    at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:410)[149:org.eclipse.jetty.server:7.2.2.v20101205] 
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:508)[144:org.eclipse.jetty.io:7.2.2.v20101205] 
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.access$000(SelectChannelEndPoint.java:34)[144:org.eclipse.jetty.io:7.2.2.v20101205] 
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:40)[144:org.eclipse.jetty.io:7.2.2.v20101205] 
    at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:451)[143:org.eclipse.jetty.util:7.2.2.v20101205] 
    at java.lang.Thread.run(Thread.java:595)[:1.5.0_22] 
Caused by: org.apache.servicemix.nmr.api.ServiceMixException: java.lang.NullPointerException 
    at org.apache.servicemix.cxf.transport.nmr.NMRDestination.process(NMRDestination.java:151)[203:org.apache.servicemix.cxf.transport.nmr:4.3.0] 
    at org.apache.servicemix.nmr.core.InternalEndpointWrapper.process(InternalEndpointWrapper.java:86)[83:org.apache.servicemix.nmr.core:1.4.0] 
    at org.apache.servicemix.nmr.core.ChannelImpl.process(ChannelImpl.java:255)[83:org.apache.servicemix.nmr.core:1.4.0] 
    at org.apache.servicemix.nmr.core.ChannelImpl$1.run(ChannelImpl.java:215)[83:org.apache.servicemix.nmr.core:1.4.0] 
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651)[:1.5.0_22] 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676)[:1.5.0_22] 
    ... 1 more 
Caused by: java.lang.NullPointerException 
    at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1183)[116:org.apache.cxf.bundle:2.3.2] 
    at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:427)[116:org.apache.cxf.bundle:2.3.2] 
    at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:380)[116:org.apache.cxf.bundle:2.3.2] 
    at org.apache.servicemix.cxf.transport.nmr.NMRMessageHelper.convertMessageToInputStream(NMRMessageHelper.java:43)[203:org.apache.servicemix.cxf.transport.nmr:4.3.0] 
    at org.apache.servicemix.cxf.transport.nmr.NMRDestination.process(NMRDestination.java:127)[203:org.apache.servicemix.cxf.transport.nmr:4.3.0] 
    ... 6 more 

回答

1

看起來我過去兩天一直在處理完全相同的問題。我相信我現在已經解決了它。以下是我發現的:

StaxUtils中的NPE似乎歸因於sourcejavax.xml.transform.Source)是null。當exchange.getIn().getBody(Source.class)NMRDestination類中返回null時,它可以是null。這是事情變得有點醜陋的地方。讓我們退後一步。

要查看您的消息是否有身體,當它進入您的身體時,您需要打開TRACE日誌級別。您可以使用log:set TRACE命令在servicemix控制檯中執行此操作。 ExchangeUtils#display(Exchange)只有在TRACE中打印出正文才能調用,即使在DEBUG中也是如此。有了TRACE,你就會看到諸如此類的東西:

id:  1520804564-51998-1331328769981-0-3 
    mep:  InOut 
    status: Active 
    role:  Consumer 
    target: ... 
    properties: [ ] 
    In: [ 
     content: 
     ] 

In.content部分本質上是消息的正文。我相信你們的交流有着和我一樣的身體。這意味着它在NMR/Camel路由模式中的某個地方「丟失」了。

exchange.getIn().getBody(Source.class)經過一個特殊的轉換邏輯,如果某些東西沒有點擊,它可能會默默地(!)返回null。看看org.apache.camel.impl.converter.BaseTypeConverterRegistry#doConvertTo()

當我在閱讀TRACE日誌時,我注意到另一個關於org.apache.xml.serializer.ToXMLStream的微妙(幾乎是FYI)跟蹤消息對我的軟件包不可見。我認爲NMR沒有將消息轉換爲Source對象,並且沒有告訴我任何關於它的信息。

SOLUTION:我最終加入org.apache.xml.serializerImport-Package行家指令與org.apache.xalan沿(一旦我添加了串行輸入的是炸燬了,接下來的事情就是ClassNotFountException抱怨org.apache.xalan.xsltc.trax.DOM2SAX)。一切都在運行時間,全都在lib/endorsed之前,直到現在,我的服務包才發現它。

它現在可以工作,我的信息在目標端點。還有一點需要注意的是駱駝內容的streamCache屬性。在最新版本的Camel中沒有默認緩存流資源,並且除非緩存,否則您的代碼將無法從流中多次讀取。

現在仍然存在的問題是爲什麼我必須讓服務「意識到」這些依賴關係NMR /駱駝需要沿着路線發送我的消息。沒有任何意義。