Link to home
Start Free TrialLog in
Avatar of pzaprianov
pzaprianovFlag for United States of America

asked on

JAXB error "doesnt contain ObjectFactory.class or jaxb.index"

Hi all,

I've got javax.xml.bind.JAXBException: "jaxb.Foo" doesnt contain ObjectFactory.class or jaxb.index

I am trying to do an unmarshall with JaxB, I have the following:

Any idea?

class Foo {
  @XmlElement
  String a;
  @XmlElement(required=true)
  String b;
  @XmlElement
  String c;
}
 
-------------------------------------------------------
myJaxb.java
-------------------------------------------------------
 
    JAXBContext jc = JAXBContext.newInstance( "jaxb.Foo" );
      
          Unmarshaller u = jc.createUnmarshaller();
      
          Foo fooObj = (Foo)u.unmarshal(
              new FileInputStream( "foo.xml" ) ); 
 
---------------------------------------
foo.xml
----------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<Foo>
         <a>1</a>
         <b>2</b>
         <c>3</c>
</Foo>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of schybert
schybert

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pzaprianov

ASKER

Excellent solution, just what i was looking for, i am going to post another question and I hope you can help me again. Thank you