JAXB 转换在 Mule 中不起作用
JAXB transformation not working in Mule
我正在按照 Mule 教程执行 JAXB 转换。下面是我得到的异常跟踪,然后是我的配置
我在 JDK 1.7
上使用 Mule 3.6.2 EE
WARN 2015-07-18 12:41:34,326 [main] org.mule.config.spring.MuleArtifactContext: Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_muleNotificationManager': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'JAXB_Context': Invocation of init method failed; nested exception is javax.xml.bind.JAXBException: Provider com.sun.xml.bind.v2.ContextFactory could not be instantiated: javax.xml.bind.JAXBException: "com.mulesoft.training" doesnt contain ObjectFactory.class or jaxb.index
- with linked exception:
[javax.xml.bind.JAXBException: "com.mulesoft.training" doesnt contain ObjectFactory.class or jaxb.index]
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:173) ~[spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102) ~[spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1467) ~[spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246) ~[spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191) ~[spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:632) ~[spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
我的 XML 配置如下所示
<http:request-config name="United_REST_Request_Configuration" host="localhost" port="8112" basePath="essentials/united/flights" doc:name="HTTP Request Configuration"/>
<http:request-config name="Bank_REST_Request_Configuration" host="training.cloudhub.io" port="80" basePath="/build/banking/rest" doc:name="HTTP Request Configuration">
<http:raml-api-configuration location="http://localhost:8112/build/banking/raml"/>
</http:request-config>
<ws:consumer-config name="Delta_Web_Service_Consumer" wsdlLocation="http://localhost:8112/essentials/delta?wsdl" service="TicketServiceService" port="TicketServicePort" serviceAddress="http://localhost:8112/essentials/delta" doc:name="Web Service Consumer"/>
<mulexml:jaxb-context name="JAXB_Context" packageNames="com.mulesoft.training" doc:name="JAXB Context" />
<flow name="getDeltaFlightsFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/delta" allowedMethods="GET" doc:name="/delta"/>
<ws:consumer config-ref="Delta_Web_Service_Consumer" operation="listAllFlights" doc:name="listAllFlightsWS"/>
<mulexml:jaxb-xml-to-object-transformer returnClass="com.mulesoft.training.FlightArray" jaxbContext-ref="JAXB_Context" doc:name="XML to JAXB Object"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</flow>
我的包结构如下所示
eclipse (mule studio) 中的 Mule 项目是 Java 项目类型的扩展。 Java 项目中的所有资源都必须进入资源类型 class 路径条目,简而言之,src/main/resources
是这些类型的文件必须存在的位置。您可以在那里创建一个包并放置资源,它应该可以工作。
对于 mule 项目从中获取结构的 Maven 也是如此。
我正在按照 Mule 教程执行 JAXB 转换。下面是我得到的异常跟踪,然后是我的配置
我在 JDK 1.7
上使用 Mule 3.6.2 EEWARN 2015-07-18 12:41:34,326 [main] org.mule.config.spring.MuleArtifactContext: Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_muleNotificationManager': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'JAXB_Context': Invocation of init method failed; nested exception is javax.xml.bind.JAXBException: Provider com.sun.xml.bind.v2.ContextFactory could not be instantiated: javax.xml.bind.JAXBException: "com.mulesoft.training" doesnt contain ObjectFactory.class or jaxb.index
- with linked exception:
[javax.xml.bind.JAXBException: "com.mulesoft.training" doesnt contain ObjectFactory.class or jaxb.index]
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:173) ~[spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102) ~[spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1467) ~[spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246) ~[spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191) ~[spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:632) ~[spring-beans-3.2.13.RELEASE.jar:3.2.13.RELEASE]
我的 XML 配置如下所示
<http:request-config name="United_REST_Request_Configuration" host="localhost" port="8112" basePath="essentials/united/flights" doc:name="HTTP Request Configuration"/>
<http:request-config name="Bank_REST_Request_Configuration" host="training.cloudhub.io" port="80" basePath="/build/banking/rest" doc:name="HTTP Request Configuration">
<http:raml-api-configuration location="http://localhost:8112/build/banking/raml"/>
</http:request-config>
<ws:consumer-config name="Delta_Web_Service_Consumer" wsdlLocation="http://localhost:8112/essentials/delta?wsdl" service="TicketServiceService" port="TicketServicePort" serviceAddress="http://localhost:8112/essentials/delta" doc:name="Web Service Consumer"/>
<mulexml:jaxb-context name="JAXB_Context" packageNames="com.mulesoft.training" doc:name="JAXB Context" />
<flow name="getDeltaFlightsFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/delta" allowedMethods="GET" doc:name="/delta"/>
<ws:consumer config-ref="Delta_Web_Service_Consumer" operation="listAllFlights" doc:name="listAllFlightsWS"/>
<mulexml:jaxb-xml-to-object-transformer returnClass="com.mulesoft.training.FlightArray" jaxbContext-ref="JAXB_Context" doc:name="XML to JAXB Object"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</flow>
我的包结构如下所示
eclipse (mule studio) 中的 Mule 项目是 Java 项目类型的扩展。 Java 项目中的所有资源都必须进入资源类型 class 路径条目,简而言之,src/main/resources
是这些类型的文件必须存在的位置。您可以在那里创建一个包并放置资源,它应该可以工作。
对于 mule 项目从中获取结构的 Maven 也是如此。