users@jaxb.java.net

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

From: Gregory Denton <greg.denton_at_gmail.com>
Date: Wed, 29 Apr 2009 18:43:42 -0700

OK, it's working now. Looks like it was related to the junit version,
possibly in conjunction with tests in another pkg (?). I changed from
4.1 to 4.5 and no exception. I have no idea why. Thanks.

On Wed, Apr 29, 2009 at 5:20 PM, Gregory Denton <greg.denton_at_gmail.com> wrote:
> 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.
>