私は castor 1.3.3-rc1 を使用していますが、この問題に戸惑っています。マニュアルを数回読んだことがあり、ここですべてを行ったと思いますが、取得し続けます:
java.lang.IllegalArgumentException: object is not an instance of declaring class{File: [not available]; line: 4; column: 43}
私のxmlをアンマーシャリングするとき。
これらは私のJavaクラスです:
public class ReportConfiguration {
private List<ColumnMapping> columnMappings;
// getters and setters omitted
}
public class ColumnMapping {
private int index;
private String label;
private String sumTotal;
// getters and setters omitted
}
これは、上記の Java クラスにアンマーシャリングされる私の xml データ ファイルです。
<reportConfiguration>
<columnMappings>
<columnMapping index="0" label="Login"/>
<columnMapping index="1" label="Group"/>
<columnMapping index="2" label="Profit" sumTotal="yes"/>
</columnMappings>
</reportConfiguration>
そして、これは私のキャスターマッピングファイルです
<mapping>
<class name="my.company.ReportConfiguration">
<map-to xml="reportConfiguration"/>
<field name="columnMappings" collection="arraylist" type="my.company.ColumnMapping">
<bind-xml name="columnMappings"/>
</field>
</class>
<class name="my.company.ColumnMapping">
<map-to xml="columnMapping"/>
<field name="index" type="integer" required="true">
<bind-xml name="index" node="attribute"/>
</field>
<field name="label" type="string" required="true">
<bind-xml name="label" node="attribute"/>
</field>
<field name="sumTotal" type="string">
<bind-xml name="sumTotal" node="attribute"/>
</field>
</class>
</mapping>
Spring OXM を使用し、アプリケーション コンテキストに org.springframework.oxm.castor.CastorMarshaller インスタンスを作成し、Unmarshaller インスタンスを依存関係として注入しました。アンマーシャリングするときは、次のようにします。
ReportConfiguration config = (ReportConfiguration) unmarshaller.unmarshall(new StreamSource(inputStream));
誰が私が間違っていたのか/他にどのようにこの問題をデバッグできるのかを見つけることができますか?