我在解组然后编组方面遇到了问题。
我的意见
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<GetDeadlineOffset>
<deadlineCode>DC1</deadlineCode>
<parameters>
<parameter name="P1">Param 1</parameter>
<parameter name="P2">Param 2</parameter>
</parameters>
</GetDeadlineOffset>
我的映射:
<?xml version="1.0" encoding="UTF-8"?>
<class name="com.evolvus.training.camel.domain.GetDeadlineOffset">
<map-to xml="GetDeadlineOffset"/>
<field name="DeadlineCode">
<bind-xml name="deadlineCode" />
</field>
<field name="parameters" type="com.evolvus.training.camel.domain.Parameter" collection="collection">
<bind-xml name="parameter" location="parameters">
<class name="com.evolvus.training.camel.domain.Parameter">
<field name="Name">
<bind-xml name="name" node="attribute" />
</field>
<field name="Value">
<bind-xml node="text"/>
</field>
</class>
</bind-xml>
</field>
</class>
我的班级: Parameter.java
public class Parameter {
private String name = null;
private String value = null;
//setters and getters
}
GetDeadlineOffset.java
public class GetDeadlineOffset {
private String deadlineCode = null;
private Vector<Parameter> paramList = new Vector<Parameter>();
//setters and getters
}
ISO3166Processor.java
public class ISO3166Processor implements Processor {
public void process(Exchange arg0) throws Exception {
GetDeadlineOffset iso4217 = (GetDeadlineOffset) arg0.getIn().getBody();
System.out.println("Unmarshalled Object is: " + iso4217);
arg0.setOut(arg0.getIn());
arg0.getOut().setBody(gdo);
arg0.getOut().setHeaders(arg0.getIn().getHeaders());
}
}
路线:
<bean id="currencyProcessor" class="com.evolvus.training.camel.processor.ISO3166Processor" />
<camelContext xmlns="http://camel.apache.org/schema/spring">
<dataFormats>
<castor id="iso3166"
mappingFile="castor/castor-mapping.xml"
packages="com.evolvus.training.camel.domain"/>
</dataFormats>
<route>
<from uri="file:src/data/in?noop=true"/>
<unmarshal ref="iso3166"/>
<log message="unmarshall" />
<process ref="currencyProcessor" />
<log message="processed" />
<marshal ref="iso3166" />
<log message="reachng output2" />
<to uri="file:src/data/out?fileName=${id}" />
<stop></stop>
</route>
</camelContext>
例外:
Exhausted after delivery attempt: 1 caught:
java.lang.NullPointerException java.lang.NullPointerException
at org.exolab.castor.mapping.Mapping.loadMapping(Mapping.java:276)
[org.apache.servicemix.bundles.castor-1.3.1_2.jar:] –
The class for the root element 'GetDeadlineOffset' could not be found.
File: [not available]; line: 2; column: 20}
at org.exolab.castor.xml.Unmarshaller.convertSAXExceptionToMarshalException(Unmarshaller.java:794)
[org.apache.servicemix.bundles.castor-1.3.1_2.jar:]
如果我编组它,请考虑切换到使用Marshaller实例并调用其中一个marshal()
方法*。请给我解决这个问题。如何用驼峰调用非静态马歇尔方法?
答案 0 :(得分:0)
此例外:
java.lang.NullPointerException java.lang.NullPointerException
at org.exolab.castor.mapping.Mapping.loadMapping(Mapping.java:276)
[org.apache.servicemix.bundles.castor-1.3.1_2.jar:] –
表示施法者无法找到您的mapping.xml
。确保它包含在jar文件/ classes目录中。