Castor Mappingexception

Zimmi25

Neues Mitglied
Hallo!

Bin noch neu bei Java-Programmieurng und habe folgendes Problem

ich erstelle ein Programm dass eine txt datei in eine xml umwandelt. (arbeite dabei mit castor-plugin und eclipse)

dabei taucht nun das folgende dilemma auf. in einer liste ist noch eine weitere liste geschachtelt. dann erscheint folgende fehlermeldung:

org.exolab.castor.mapping.MappingException: The method getArticle_Ref/isArticle_REF in class anwendungTXTinXML.ArticleData accepting/returning object of type class java.util.ArrayList was not found.



ich benutze zum ausgeben in xml eine mapping-datei.

Code der betroffenen Stelle in der Mapping-Datei:

...
<class name="anwendungTXTinXML.Data">
<map-to xml="Anwendung" />
<field name="codierung" type="java.lang.String">
...

<field name="articleData" type="anwendungTXTinXML.ArticleData" collection="arraylist">
<bind-xml name="ArticleData" />
</field>

/class>

...

<class name="anwendungTXTinXML.ArticleData">

<field name="id" type="java.lang.String">
<bind-xml name="Id" node="element" />
</field>
...
<field name="article_REF" type="anwendungTXTinXML.Article_REF" collection="arraylist">
<bind-xml name="Article_REF" />
</field>
/class>
....


Java Code:
try{

OutputStreamWriter writer = new OutputStreamWriter(
new FileOutputStream(
path +"Ausgabe.xml"),"UTF-8");

Marshaller marshaller = new Marshaller(writer);

File f = new File(path+ "AnwendungMapping.xml");
InputStream inputStream = new FileInputStream(f);
InputSource mappingSource = new InputSource(inputStream);
Mapping mapping = new Mapping();
mapping.loadMapping(mappingSource);

marshaller.setEncoding("UTF-8");
marshaller.setMapping(mapping);
marshaller.marshal(data);

writer.close();
}
catch....


kurz zu marshaller.marshal(data) :
Es gibt ein Objekt Data, in dieses wird das objekt ArticleData geschrieben in welches wiederum das Objekt Article_REF geschrieben wird.

xml sollte so aussehen:
<Data>
....
<ArticleData>
....
<Article_REF>
...
</Article_REF>

</ArticleData>

</Data>


Weiß jemand wieso das nicht funktioniert?
Bzw. wo der Fehler sitzen könnte??? Sitze schon seit Stunden daran und nichts geht.....
 

turtle

Top Contributor
Setz mal direct="true". Aus der Doku
Code:
If 'direct' is set to true, Castor expects to find a class variable with the given signature:

            public <type> <name>;
          
If 'direct' is set to false or omitted, Castor will access the property though accessor methods.
 

Ähnliche Java Themen

Neue Themen


Oben