JAXB编组异常;嵌套异常是javax.xml.bind.MarshalException

时间:2015-05-20 11:53:12

标签: spring-integration

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

   <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"/>

任何人都可以帮我解决这个例外。

这是我的上下文文件:

public Cursor getData(String username){
    SQLiteDatabase db = dbHelper.getReadableDatabase();
    String sql="select * from " + tableName + " where username =?";
    Cursor cursor=database.rawQuery(sql,new String{username});
    if (cursor != null)
{   cursor.moveToFirst();}
    return cursor;
}

1 个答案:

答案 0 :(得分:0)

  

无法编组类型&#34; java.lang.String&#34;作为元素,因为它缺少@XmlRootElement注释],

因此,您的payload是String,但marshaller需要在该类上使用该注释的域Java Bean。

否则,如果您的String是有效的XML,请尝试使用不<int-ws:outbound-gateway>的{​​{1}}。