SMX的SE测试代码出错

6 views
Skip to first unread message

Jackey Ding

unread,
May 15, 2008, 9:18:14 PM5/15/08
to cxf...@googlegroups.com
Hi,
 
我在为我的SMX SE写一些测试代码,代码如下:
CxfSeComponent component = new CxfSeComponent();
container.activateComponent(component, "CxfSeComponent"); 
// Start container
container.start();           
// Deploy SU
component.getServiceUnitManager().deploy("target", getServiceUnitPath());
 
执行到上面一句的时候出了错。后来我跟踪了一下,发现在CxfSeEndpoint --> start()方法中对address的定义如下:
address = "jbi://" + ID_GENERATOR.generateSanitizedId();
        try {
            endpoint.publish(address);
        } catch (Exception e) {
            e.printStackTrace();
        }
 
 而在JettyHTTPDestination初始化的时候造成unknown protocol: jbi
public JettyHTTPDestination(
            Bus                       b,
            JettyHTTPTransportFactory ci,
            EndpointInfo              endpointInfo
    ) throws IOException {
        //Add the defualt port if the address is missing it
        super(b, ci, endpointInfo, true);
        this.transportFactory = ci;
        this.serverEngineFactory = ci.getJettyHTTPServerEngineFactory();
        nurl = new URL(endpointInfo.getAddress());
    }
 
 错误信息如下:
javax.jbi.management.DeploymentException: <component-task-result xmlns="http://java.sun.com/xml/ns/jbi/management-message">
 <component-name>CxfSeComponent</component-name>
 <component-task-result-details>
  <task-result-details>
   <task-id>start</task-id>
   <task-result>FAILED</task-result>
   <message-type>ERROR</message-type>
   <task-status-msg><msg-loc-info><loc-token/><loc-message>Unable to start service unit</loc-message></msg-loc-info></task-status-msg>
   <exception-info>
    <nesting-level>1</nesting-level>
    <msg-loc-info>
     <loc-token />
     <loc-message>org.apache.cxf.service.factory.ServiceConstructionException</loc-message>
     <stack-trace><![CDATA[javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException
 at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:258)
 at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:194)
 at org.apache.servicemix.cxfse.CxfSeEndpoint.start(CxfSeEndpoint.java:218)
 at org.apache.servicemix.common.endpoints.SimpleEndpoint.activate(SimpleEndpoint.java:55)
 at org.apache.servicemix.common.ServiceUnit.start(ServiceUnit.java:53)
 at org.apache.servicemix.common.BaseServiceUnitManager.start(BaseServiceUnitManager.java:151)
 at symphony.integration.service.TestSMXServiceDirectorImpl2.testDeployService(TestSMXServiceDirectorImpl2.java:49)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at junit.framework.TestCase.runTest(TestCase.java:168)
 at junit.framework.TestCase.runBare(TestCase.java:134)
 at junit.framework.TestResult$1.protect(TestResult.java:110)
 at junit.framework.TestResult.runProtected(TestResult.java:128)
 at junit.framework.TestResult.run(TestResult.java:113)
 at junit.framework.TestCase.run(TestCase.java:124)
 at junit.framework.TestSuite.runTest(TestSuite.java:232)
 at junit.framework.TestSuite.run(TestSuite.java:227)
 at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.apache.cxf.service.factory.ServiceConstructionException
 at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:136)
 at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:160)
 at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:322)
 at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:244)
 ... 25 more
Caused by: java.net.MalformedURLException: unknown protocol: jbi
 at java.net.URL.<init>(Unknown Source)
 at java.net.URL.<init>(Unknown Source)
 at java.net.URL.<init>(Unknown Source)
 at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.<init>(JettyHTTPDestination.java:86)
 at org.apache.cxf.transport.http_jetty.JettyHTTPTransportFactory.createDestination(JettyHTTPTransportFactory.java:116)
 at org.apache.cxf.transport.http_jetty.JettyHTTPTransportFactory.getDestination(JettyHTTPTransportFactory.java:103)
 at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:90)
 at org.apache.cxf.endpoint.ServerImpl.<init>(ServerImpl.java:69)
 at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:115)
 ... 28 more
]]></stack-trace>
    </msg-loc-info>
   </exception-info>
  </task-result-details>
 </component-task-result-details>
</component-task-result>
 at org.apache.servicemix.common.BaseServiceUnitManager.failure(BaseServiceUnitManager.java:283)
 at org.apache.servicemix.common.BaseServiceUnitManager.start(BaseServiceUnitManager.java:158)
 at symphony.integration.service.TestSMXServiceDirectorImpl2.testDeployService(TestSMXServiceDirectorImpl2.java:49)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at junit.framework.TestCase.runTest(TestCase.java:168)
 at junit.framework.TestCase.runBare(TestCase.java:134)
 at junit.framework.TestResult$1.protect(TestResult.java:110)
 at junit.framework.TestResult.runProtected(TestResult.java:128)
 at junit.framework.TestResult.run(TestResult.java:113)
 at junit.framework.TestCase.run(TestCase.java:124)
 at junit.framework.TestSuite.runTest(TestSuite.java:232)
 at junit.framework.TestSuite.run(TestSuite.java:227)
 at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

 Jackey Ding

willem

unread,
May 15, 2008, 10:08:31 PM5/15/08
to cxf-zh
不知道SE的配置文件是什么样的, 还有你的class path中是否有 cxf-rt-bindings-jbi*.jar。
从stack trace来看,应该是Transport 初始化的问题。
具体来说 jbi:// 应该是有JBITransport来负责传输的,而不是由Jetty Http 来负责。

姜宁 (Willem)
--------------------------------
http://willem.bokeland.com
http://www.ohloh.net/accounts/4473

Freeman Fang

unread,
May 15, 2008, 10:39:04 PM5/15/08
to cxf...@googlegroups.com
Willem is right
smx内部用JBI transport, 不应该用http, JBI的识别靠JBI transport lib, 估计
是你少了jar

Jackey Ding

unread,
May 15, 2008, 11:19:58 PM5/15/08
to cxf...@googlegroups.com
Thanks Willem,
 
根据你的提示,我又跟踪了一下。
在AbstractWSDLBasedEndpointFactory中创建destinationFactory的时候,在createEndpointInfo()方法中,
if (transportId == null
            && getAddress() != null) {
            DestinationFactory df = getDestinationFactory();
            if (df == null) {
               【1】
                DestinationFactoryManager dfm = getBus().getExtension(DestinationFactoryManager.class);
                df = dfm.getDestinationFactoryForUri(getAddress());
            }
           
            if (df != null) {
                transportId = df.getTransportIds().get(0);
            } else {
                //check conduits (the address could be supported on client only)
                ConduitInitiatorManager cim = getBus().getExtension(ConduitInitiatorManager.class);
                ConduitInitiator ci = cim.getConduitInitiatorForUri(getAddress());
                if (ci != null) {
                    transportId = ci.getTransportIds().get(0);
                }   
            }
        }
个人认为在【1】处应该的到一个JBI的DestinationFactory ,而实际上得到的是null。
所以造成了在后面会用Jetty Http 的DestinationFactory
if (transportId == null) {
            if (bindingInfo instanceof SoapBindingInfo) {
                // TODO: we shouldn't have to do this, but the DF is null because the
                // LocalTransport doesn't return for the http:// uris
                // People also seem to be supplying a null JMS getAddress(), which is worrying
                transportId = "http://schemas.xmlsoap.org/wsdl/soap/";               
            } else {
                transportId = "http://schemas.xmlsoap.org/wsdl/http/";
            }
        }
 
 
Jackey
2008/5/16 Freeman Fang <freema...@gmail.com>:

willem

unread,
May 15, 2008, 11:25:24 PM5/15/08
to cxf-zh
传入的 getAddress() 值是什么?
如果调用了还没有找到,那只是说明JBITransportFactory 没有被注入到Bus中。
你检查class path 了吗?

姜宁 (Willem)
--------------------------------
http://willem.bokeland.com
http://www.ohloh.net/accounts/4473

> 2008/5/16 Freeman Fang <freeman.f...@gmail.com>:
> ...
>
> 阅读更多 >>

Jackey Ding

unread,
May 15, 2008, 11:37:06 PM5/15/08
to cxf...@googlegroups.com
address是jbi://ID-192-168-1-7-119efcbff14-4-0
前面忘了说了cxf-rt-bindings-jbi-2.1.jar已经在Classpath。
在Classpath中还有CXF-2.1.jar,是不是造成了冲突。
 
jackey

2008/5/16 willem <willem...@gmail.com>:

willem

unread,
May 15, 2008, 11:59:32 PM5/15/08
to cxf-zh
对不起,我说错了 应该是 cxf-rt-transports-jbi*.jar, 这个jar里面包含了
JBITransportFactory。

姜宁 (Willem)
--------------------------------
http://willem.bokeland.com
http://www.ohloh.net/accounts/4473

On 5月16日, 上午11时37分, "Jackey Ding" <novthirt...@gmail.com> wrote:
> address是jbi://ID-192-168-1-7-119efcbff14-4-0
> 前面忘了说了cxf-rt-bindings-jbi-2.1.jar已经在Classpath。
> 在Classpath中还有CXF-2.1.jar,是不是造成了冲突。
>
> jackey
>
> 2008/5/16 willem <willem.ji...@gmail.com>:
> ...
>
> 阅读更多 >>

Freeman Fang

unread,
May 15, 2008, 11:36:03 PM5/15/08
to cxf...@googlegroups.com
在你的pom 里面加上
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-jbi</artifactId>
<version>${cxf-version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.servicemix</groupId>
<artifactId>servicemix-jbi</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-jbi</artifactId>
<version>${cxf-version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.servicemix</groupId>
<artifactId>servicemix-jbi</artifactId>
</exclusion>
</exclusions>
</dependency>

> <mailto:freema...@gmail.com>>:


>
>
> Willem is right
> smx内部用JBI transport, 不应该用http, JBI的识别靠JBI transport
> lib, 估计
> 是你少了jar
>
> willem wrote:
> > 不知道SE的配置文件是什么样的, 还有你的class path中是否有
> cxf-rt-bindings-jbi*.jar。
> > 从stack trace来看,应该是Transport 初始化的问题。
> > 具体来说 jbi:// 应该是有JBITransport来负责传输的,而不是由Jetty
> Http 来负责。
> >
> > 姜宁 (Willem)
> > --------------------------------

> > http://willem.bokeland.com <http://willem.bokeland.com/>


> > http://www.ohloh.net/accounts/4473
> >
> > On 5月16日, 上午9时18分, "Jackey Ding" <novthirt...@gmail.com

Jackey Ding

unread,
May 16, 2008, 1:51:52 AM5/16/08
to cxf...@googlegroups.com
Thanks William and Freeman,
 
加上cxf-rt-transports-jbi包就解决了。
 
Jackey

2008/5/16 Freeman Fang <freema...@gmail.com>:

Jackey Ding

unread,
May 17, 2008, 1:45:55 AM5/17/08
to cxf...@googlegroups.com
Hi,
 
还是前面那个例子,出了其它的问题,出错信息如下:
信息: Interceptor has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Unmarshalling Error: unexpected element (uri:"http://service.integration.symphony/", local:"findWSDL"). Expected elements are (none)
 at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:642)
 at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:555)
 at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:64)
 at org.apache.cxf.binding.jbi.interceptor.JBIWrapperInInterceptor.handleMessage(JBIWrapperInInterceptor.java:124)
 at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221)
 at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78)
 at org.apache.cxf.transport.jbi.JBIDispatcherUtil.dispatch(JBIDispatcherUtil.java:148)
 at org.apache.servicemix.cxfse.CxfSeEndpoint.process(CxfSeEndpoint.java:223)
 at org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:538)
 at org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:490)
 at org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeCycle.java:46)
 at org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:610)
 at org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:170)
 at org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:167)
 at org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 at java.lang.Thread.run(Unknown Source)
Caused by: javax.xml.bind.UnmarshalException
 - with linked exception:
[javax.xml.bind.UnmarshalException: unexpected element (uri:"http://service.integration.symphony/", local:"findWSDL"). Expected elements are (none)]
 at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:421)
 at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360)
 at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:330)
 at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:628)
 ... 17 more
Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"http://service.integration.symphony/", local:"findWSDL"). Expected elements are (none)
 at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:603)
 at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:244)
 at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:239)
 at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:116)
 at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:1009)
 at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:446)
 at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:427)
 at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStartElement(StAXStreamConnector.java:275)
 at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:209)
 at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:358)
 ... 19 more
Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"http://service.integration.symphony/", local:"findWSDL"). Expected elements are (none)
 ... 29 more
服务端代码如下:
@WebService(name="SmxServiceDirectorImpl", targetNamespace="http://service.integration.symphony/")
public class SmxServiceDirectorImpl implements ServiceDirector { 
 
 @WebMethod(operationName="findWSDL")
 @ResponseWrapper(className="symphony.integration.service.FindWSDLResponse", localName="findWSDLResponse", targetNamespace="http://service.integration.symphony/")
 @RequestWrapper(className="symphony.integration.service.FindWSDL", localName="findWSDL", targetNamespace="http://service.integration.symphony/")
 public String findWSDL(String serviceName) throws SISerivceNotFoundException {return "";}
客户端代码:
CxfSeComponent component = new CxfSeComponent();
      container.activateComponent(component, "CxfSeComponent"); 
     
      // Start container
      container.start();          
     
      // Deploy SU
      component.getServiceUnitManager().deploy("target", getServiceUnitPath());
      component.getServiceUnitManager().init("target", getServiceUnitPath());
      component.getServiceUnitManager().start("target");
 
       client = new DefaultServiceMixClient(container);
         io = client.createInOutExchange();
         io.setService(new QName("http://service.integration.symphony/", "SmxServiceDirectorImplService"));
         //io.setInterfaceName(new QName("http://service.integration.symphony/", "ServiceDirector"));
         io.setOperation(new QName("http://service.integration.symphony/", "findWSDL"));
        
         log.info("test clientProxy");
        io.getInMessage().setContent(new StringSource(
                 "<message xmlns='http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper'>"
               + "<part>"
               + "<findWSDL xmlns='http://service.integration.symphony/'>"
               + "<requestType>"
               + "{http://service.integration.symphony/}SmxServiceDirectorImplService:ServiceDirectorPort"
               + "</requestType>"
               + "</findWSDL>"
               + "</part> "
               + "</message>")
         );
       client.sendSync(io);
       assertNotNull(io.getOutMessage());
 
Jackey
 
2008/5/16 Jackey Ding <novth...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages