• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error while unmarshalling xml (Castor 1.3, JDK 1.5)

 
Mysore Prashanth
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Athena Pallas", please check your private messages regarding an important administrative matter.

Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic