wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes Error while unmarshalling xml (Castor 1.3, JDK 1.5) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Error while unmarshalling xml (Castor 1.3, JDK 1.5)" Watch "Error while unmarshalling xml (Castor 1.3, JDK 1.5)" New topic
Author

Error while unmarshalling xml (Castor 1.3, JDK 1.5)

Mysore Prashanth
Greenhorn

Joined: Jun 10, 2010
Posts: 3
Hi,
Being new to xml parsing I am facing the below error when trying to unmarshall a xml file. Request your expert advice to resolve this.


-----Error Message-----
org.exolab.castor.xml.MarshalException: com.castor.Book{File: [not available]; line: 2; column: 7}
at org.exolab.castor.xml.Unmarshaller.convertSAXExceptionToMarshalException(Unmarshaller.java:794)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:760)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:626)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:840)
at com.castor.UnmarshalBook.main(UnmarshalBook.java:13)
Caused by: java.lang.InstantiationException: com.castor.Book
at java.lang.Class.newInstance0(Class.java:335)
at java.lang.Class.newInstance(Class.java:303)
at org.exolab.castor.util.DefaultObjectFactory.createInstance(DefaultObjectFactory.java:107)
at org.exolab.castor.xml.UnmarshalHandler.createInstance(UnmarshalHandler.java:2579)
at org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1711)
at org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1436)
......

The java file used for unmarshall is

-----Unmarshall-----
package com.castor;

import java.io.*;
import org.exolab.castor.xml.Unmarshaller;

public class UnmarshalBook
{
public static void main (String[] args)
{
try
{
FileReader reader = new FileReader("Book.xml");
Book book = (Book)Unmarshaller.unmarshal(Book.class, reader);
System.out.println(book.getIsbn());
System.out.println(book.getAuthorNames());
System.out.println(book.getTitle());

}
catch (IOException ioe)
{
ioe.printStackTrace();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}


And the XML file
-----xml file-----
<?xml version="1.0" encoding="UTF-8"?>
<book>
<isbn>99409989</isbn>.
<title>Malcolm Gladwell</title>
<author-names>Outliers</author-names>
</book>


Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18167
    
    8

"Athena Pallas", please check your private messages regarding an important administrative matter.

Thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error while unmarshalling xml (Castor 1.3, JDK 1.5)
 
Similar Threads
XML Cator Parsing Exception
Castor Help with unmarshalling
[Castor] "unmarshalling exception: unable to find FieldDescriptor for"
Caused by: java.lang.InstantiationException
problem with loading mapping.xml