3

Camel 2.10.3を使用しています

これが私のラクダのコンテキストです:

  <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring">

    <endpoint id="webserviceStart" uri="direct:webserviceStart"/>

    <dataFormats>
      <jaxb id="jaxb" prettyPrint="true"
        contextPath="com.jaxbtest.package" />
    </dataFormats>

    <route id="myRoute">
      <from ref="webserviceStart" />
      <marshal ref="jaxb" />
      <to uri="spring-ws:http://wshost:8010/service"/>
      <unmarshal ref="jaxb" />
    </route>

  </camelContext>

このコードは機能します:

@Component
public class WebserviceClient
{
    @EndpointInject( ref = "webserviceStart" )
    ProducerTemplate _producer;

    public Response invoke( Request input )
    {
        return ( Response ) _producer.sendBody( input ).getOut().getBody();
    }
}

このコード ( http://camel.apache.org/pojo-producing.htmlの「@Produce を使用してコードから Camel API を非表示にする」セクションに従う) は、次のことを行いません。

@Component
public class WebserviceClient
{
    public static interface MyWebservice
    {
      Response invoke( @Body Request body );
    }

    @EndpointInject( ref = "webserviceStart" )
    MyWebservice _producer;

    public Response invoke( Request input )
    {
        return ( Response ) _producer.invoke( input );
    }
}

それは例外をスローします:

Caused by: java.io.IOException: javax.xml.bind.JAXBException: class org.apache.camel.component.bean.BeanInvocation nor any of its super class is known to this context.
    at org.apache.camel.converter.jaxb.JaxbDataFormat.marshal(JaxbDataFormat.java:103)
    at org.apache.camel.processor.MarshalProcessor.process(MarshalProcessor.java:59)
    at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

これがキャメルの既知のバグである場合、それに関連する問題を知っている人はいますか? このために新しい JIRA を作成する必要がありますか? これは、POJO プロデュースの非常に単純な使用例のようです。

4

1 に答える 1

-2

通常、このエラーが発生した場合は、JAXB コンテキストでクラスのリストを設定していないことを意味します。

あなたはJAVA DSLでやります -

 JAXBContext context =  JAXBContext.newInstance('your classes');
            JaxbDataFormat jaxb = new JaxbDataFormat();
            jaxb.setContext(context);

次に、カスタムデータフォーマット「jaxb」をマーシャル/アンマーシャル参照として使用します。

ありがとう!

于 2013-04-29T05:16:21.657 に答える