gpt4 book ai didi

java - JAXB 转换在 Mule 中不起作用

转载 作者:行者123 更新时间:2023-12-02 04:30:53 26 4
gpt4 key购买 nike

我正在按照 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>

我的包结构如下所示 enter image description here

最佳答案

eclipse(mule studio)中的Mule项目是Java项目类型的扩展。 Java 项目中的所有资源都必须位于资源类型的类路径条目中,简而言之,src/main/resources 是这些类型的文件必须存在的位置。您可以在那里创建一个包并放置资源,它应该可以工作。

对于 Maven 来说也是如此,Mule 项目从中获得了结构。

关于java - JAXB 转换在 Mule 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31486716/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com