Note that there are some explanatory texts on larger screens.

plurals
  1. POException with Simple XML framework deserialization
    primarykey
    data
    text
    <p>I'm facing a problem to deserialize an XML file which have successfully been serialized with the <a href="http://simple.sourceforge.net/">Simple XML Serialization</a> framework (simpleframework.org). </p> <p>There is <a href="http://simple.sourceforge.net/download/stream/doc/javadoc/org/simpleframework/xml/core/PersistenceException.html">an exception</a> thrown:</p> <pre class="lang-none prettyprint-override"><code>org.simpleframework.xml.core.PersistenceException: Constructor not matched for class projet.sarelo.Note </code></pre> <p>This is the call: </p> <pre><code>Serializer serializer = new Persister(); File xmlFile = new File(path); ContactList contactList = serializer.read(ContactList.class, xmlFile); &lt;== Error </code></pre> <p>My ContactList.java</p> <pre><code>@Root(strict=false, name="ContacList") public class ContactList { @ElementArray (name = "Contacts") Contact [] contact; } </code></pre> <p>My Note.java</p> <pre><code>public class Note { @Element(required=false) private String note; public Note(String note) { super(); this.note = note; } public String getNote() { return note; } } </code></pre> <p>My Contact.java</p> <pre><code>@Root public class Contact { @Attribute(name = "id") public String id; @Element(name="Nom", required=false) String name; @ElementArray(name="Phones", required=false) Phone [] phone; @ElementArray(name = "Emails", required=false) Email [] email; @ElementArray(name = "Adresses", required=false) Adresses [] adresses; @ElementArray(name = "Notes", required=false) Note [] note; public Contact(String id, String name) { super(); this.id = id; this.name = name; } public String getName() { return name; } public String getId(){ return id; } } </code></pre> <p>And this is the XML file I'm trying to deserialize.</p> <pre class="lang-xml prettyprint-override"><code>&lt;ContactList&gt; &lt;Contacts length="5"&gt; &lt;contact id="1"&gt; &lt;Adresses length="0"/&gt; &lt;Emails length="0"/&gt; &lt;Notes length="1"&gt; &lt;note&gt; &lt;note&gt;dgfdg&lt;/note&gt; &lt;/note&gt; &lt;/Notes&gt; &lt;/contact&gt; &lt;contact id="2"&gt; &lt;Adresses length="1"&gt; &lt;adresses&gt; &lt;city&gt;Paris &lt;/city&gt; &lt;postcode&gt;751234 &lt;/postcode&gt; &lt;state&gt;France&lt;/state&gt; &lt;street&gt;Pignon&lt;/street&gt; &lt;/adresses&gt; &lt;/Adresses&gt; &lt;Emails length="1"&gt; &lt;email type="home"&gt; &lt;home&gt;nicolas.sarkozy@elysee.fr&lt;/home&gt; &lt;/email&gt; &lt;/Emails&gt; &lt;Nom&gt;Nicolas Sarkozy &lt;/Nom&gt; &lt;Notes length="1"&gt; &lt;note&gt; &lt;note&gt;Je suis le president de toute la france. Le grand president&lt;/note&gt; &lt;/note&gt; &lt;/Notes&gt; &lt;Phones length="2"&gt; &lt;phone&gt; &lt;home&gt;+33 1234&lt;/home&gt; &lt;/phone&gt; &lt;phone&gt; &lt;mobile&gt;+33 0612&lt;/mobile&gt; &lt;/phone&gt; &lt;/Phones&gt; &lt;/contact&gt; ... &lt;/Contacts&gt; &lt;/ContactList&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload