• Post Reply Bookmark Topic Watch Topic
  • New Topic

XML-JAXB ValidationException  RSS feed

Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have a sample aplication, to unmarshal the data from the xml file. Please go through the below code and help me out.

public Test{
public Test() {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(new File("Customer.xml"));

JAXBContext jc = JAXBContext.newInstance("generated", this.getClass().getClassLoader());

Unmarshaller unm = jc.createUnmarshaller();

Validator validator = jc.createValidator();

Customer cust = (Customer) unm.unmarshal(new FileInputStream("Customer.xml"));

catch(ValidationException ve){
catch (Exception error) {

public static void main(String[] args) {
new Test();


javax.xml.bind.ValidationException: the object parameter to validate() or validateRoot() is not validatable
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!