users@jaxb.java.net

jaxb.index exists but is ignored, exception on JAXBContext.newInstance

From: Gregory Denton <greg.denton_at_gmail.com>
Date: Wed, 29 Apr 2009 17:20:05 -0700

I had a test case for unmarshalling working but it is now broken and I
can't figure out why. I fooled around with schemagen and a few other
seemingly unrelated things (mostly maven stuff which I backed out to
no avail) since the test last worked. The code is very simple as I am
just starting out:

package my.company.pkg;
...
@XmlRootElement(name="user")
@XmlType(name="User")
@XmlAccessorType(XmlAccessType.NONE)
public class User {
    @XmlElement
    private String name;
    public String getName() {
        return name;
    }
}

Test case contains:

package my.company.pkg;
...
public class UserTest {
    @Test
    public void userUnmarshal() throws Exception {
        JAXBContext jc = JAXBContext.newInstance("my.company.pkg");
        Unmarshaller unmar = jc.createUnmarshaller();
     ....

Using Eclipse/maven, files are in:
src/main/java/my/company/pkg/User.class, package-info.class, jaxb.index
src/test/java/my/company/pkg/UserTest.class

jaxb.index has one line:
User

Running the test produces an exception on the newInstance:
javax.xml.bind.JAXBException: "my.company.pkg" doesnt contain
ObjectFactory.class or jaxb.index

Thanks.