JAXB封送处理异常;嵌套的异常是javax.xml.bind.MarshalException

纳拉朱

我正在从文件中读取数据并验证号码并调用webservice。调用webservice时出现以下错误。

[org.springframework.integration.ws.MarshallingWebServiceOutboundGateway] org.springframework.integration.ws.MarshallingWebServiceOutboundGateway#0 received message: GenericMessage [payload=1000213569, headers={timestamp=1432121523488, id=fbdb4e0d-d124-1620-8b41-c8dfea69069c, correlationId=e68bb811-7e9e-b86b-0b28-c24a2e3c02c0, sequenceSize=0, sequenceNumber=2}]
14:32:03.488 DEBUG [task-scheduler-1][org.springframework.integration.transformer.MessageTransformingHandler] org.springframework.integration.transformer.MessageTransformingHandler@7f422265 received message: ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: error occurred in message handler [org.springframework.integration.ws.MarshallingWebServiceOutboundGateway#0]; nested exception is org.springframework.oxm.MarshallingFailureException: JAXB marshalling exception; nested exception is javax.xml.bind.MarshalException
 - with linked exception:
[com.sun.istack.internal.SAXException2: unable to marshal type "java.lang.String" as an element because it is missing an @XmlRootElement annotation], headers={timestamp=1432121523488, id=1cf537f4-0789-d188-2563-6d5aab55b942}]
14:32:03.488 DEBUG [task-scheduler-1][org.springframework.integration.file.FileWritingMessageHandler] org.springframework.integration.file.FileWritingMessageHandler@4ee05628 received message: GenericMessage [payload=org.springframework.messaging.MessageHandlingException: error occurred in message handler [org.springframework.integration.ws.MarshallingWebServiceOutboundGateway#0]; nested exception is org.springframework.oxm.MarshallingFailureException: JAXB marshalling exception; nested exception is javax.xml.bind.MarshalException
 - with linked exception:

任何机构都可以帮助我解决此异常。

这是我的上下文文件:

   <int-sftp:inbound-channel-adapter id="sftpAdapterAutoCreate"
          session-factory="sftpSessionFactory" filename-pattern="*.*"
          remote-directory="/testSFTP/inbox/" local-directory="file:input"
          auto-create-local-directory="true" auto-startup="true"
          delete-remote-files="false" local-filename-generator-expression="#this"
          temporary-file-suffix=".writing">
          <int:poller fixed-delay="60000" max-messages-per-poll="10" />
   </int-sftp:inbound-channel-adapter>

   <int:splitter input-channel="sftpAdapterAutoCreate"
          output-channel="routingChannel"
          expression="T(org.apache.commons.io.FileUtils).lineIterator(payload)" />


   <int:channel id="routingChannel" />

   <int:filter input-channel="routingChannel" output-channel="routingChannel2" discard-channel="errorChannel"
          id="validateFormat" method="accept" ref="NinValidatorClass">       </int:filter>

   <int:channel id="routingChannel2"/>

   <int:channel id="errorChannel" >
   </int:channel>

   <int:transformer
          expression="payload"
          output-channel="routingChannel3" auto-startup="true" input-channel="routingChannel2" />

          <int:transformer
          expression="payload?.toString()"
          output-channel="errorChannel2" auto-startup="true" input-channel="errorChannel" />

   <int:channel id="routingChannel3">
   <int:interceptors>
   <int:wire-tap channel="loggingChannel"/>
   </int:interceptors>
   </int:channel>

   <int:channel id="errorChannel2"/>


   <int-file:outbound-channel-adapter channel="wsResponseChannel"
          id="filesOut" auto-create-directory="true" directory="file:target/output"
          filename-generator-expression="'nins.txt.completed'" mode="APPEND"></int-file:outbound-channel-adapter>


   <int-file:outbound-channel-adapter channel="errorChannel2"
          id="errorOut" auto-create-directory="true" directory="file:target/output"
          filename-generator-expression="'nins.txt.error'" mode="APPEND"></int-file:outbound-channel-adapter>

   <!--  -->
   <int:channel id="wsResponseChannel" />

 <int-ws:outbound-gateway id="ws-gateway" uri="http://localhost:8080/ws/WS/RetriveCitizenInfo"  request-channel="routingChannel3" reply-channel="wsResponseChannel"
      marshaller="marshaller" unmarshaller="marshaller"> 
 </int-ws:outbound-gateway>

 <oxm:jaxb2-marshaller id="marshaller"  context-path="agenciesWs.wsdl"/>
阿特姆·比兰(Artem Bilan)

由于缺少@XmlRootElement批注,因此无法将类型“ java.lang.String”作为元素编组],

因此,您payload是String,但是marshaller需要一个在类上带有该批注的域Java Bean。

否则,如果你的字符串是有效的XML,尽量使用<int-ws:outbound-gateway>marshaller

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

球衣休息服务,显示异常javax.ws.rs.WebApplicationException:javax.xml.bind.MarshalException

JaxB Unmarshal异常:javax.xml.bind.UnmarshalException:意外元素。我哪里出问题了?

javax/xml/bind/JAXBException

Jenkins - 解析抛出异常。javax.xml.bind.UnmarshalException

线程“主”中的异常java.lang.ExceptionInInitializerError原因:javax.xml.bind.DataBindingException:javax.xml.bind.JAXBException

javax.ejb.EJBException: java.rmi.MarshalException

jaxb编组时出现javax.xml.bind.PropertyException

com.sun.istack.SAXException2和javax.xml.bind.JAXBException引发的异常

如何修复线程“main”中的异常 java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter

HTTP状态500-请求处理失败;嵌套的异常是org.springframework.web.bind.annotation.support.HandlerMethodInvocationException

ClassNotFoundException:javax.xml.bind.JAXBException(再次)

用gradle构建javax / xml / bind / JAXBException

NoClassDefFoundError:javax.xml.bind.DatatypeConverter

CXF中的javax.xml.bind.UnmarshalException

javax.xml.bind无法解析

javax.xml.bind.JAXBException:不支持属性“ com.sun.xml.bind.defaultNamespaceRemap”

线程“主”中的异常javax.xml.bind.PropertyException:名称:eclipselink.media-type值:application / json

实例化休眠配置会引发错误:线程“main”中的异常 java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

Spring Boot Apache Camel(Red Hat Fuse)应用程序为 xml 定义的路由抛出异常:javax.xml.bind.UnmarshalException:意外元素

javax.xml.bind.JAXBException在模块路径或类路径上找不到JAXB-API的实现

Gradle JAXB WSDL任务失败,并出现java.lang.NoClassDefFoundError:javax / xml / bind / JAXBContext

JAXB客户端,无法读取响应:javax.xml.bind.UnmarshalException

错误:javax.xml.bind.JAXBContext(命令行)

javax.xml.bind.UnmarshalException:意外元素(uri:“”,本地:“ Group”)

javax.xml.bind.UnmarshalException:意外元素(uri:

Kafka 无法解析 javax/xml/bind/* ClassNotFoundExeption for java 12?

SQL Server JDBC中的“ NoClassDefFoundError:javax / xml / bind / DatatypeConverter”

JAX-WS:javax.xml.bind.UnmarshalException

带有NoClassDefFoundError的Android检查:javax / xml / bind / JAXBException