jaxb-ri
jaxb-ri copied to clipboard
Jakarta runtime v4 complains that jaxb.properties is missing while it tries to load jaxb.index
Dear community,
The attached project demonstrates the following problem:
- When runtime v3 is used, test is run without any issue:
$ mvn -Djaxb-api.version=3.0.0 -Djaxb-core.version=3.0.0 clean install
...
Running inner_element_value_objects.MainTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.264 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
- When runtime v4 is used, the following error occurs:
$ mvn clean install
...
Running inner_element_value_objects.MainTest
Trying to load inner_element_value_objects/jaxb.index
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.185 sec <<< FAILURE!
inner_element_value_objects.MainTest.testContextLoading() Time elapsed: 0.185 sec <<< FAILURE!
org.glassfish.jaxb.runtime.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
Package "inner_element_value_objects" is missing jaxb.properties file. Have you copied this from the generated source directory or include it in the classpath?
this problem is related to the following location:
at inner_element_value_objects.ObjectFactory
at org.glassfish.jaxb.runtime.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:83)
at org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:421)
at org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:255)
at org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1115)
at org.glassfish.jaxb.runtime.v2.ContextFactory.createContext(ContextFactory.java:144)
at org.glassfish.jaxb.runtime.v2.ContextFactory.createContext(ContextFactory.java:246)
at org.glassfish.jaxb.runtime.v2.JAXBContextFactory.createContext(JAXBContextFactory.java:58)
at jakarta.xml.bind.ContextFinder.find(ContextFinder.java:324)
at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:392)
at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:349)
at inner_element_value_objects.MainTest.testContextLoading(MainTest.java:28)
Note that jaxb.properties is a part of the project.
Two issues here:
- v3 and v4 behave differently.
- v4 tries to load the missing
jaxb.index, but complains thatjaxb.propertiesis missing. Actuallyjaxb.indexwas not generated by XJC.
v3 and v4 are not fully compatible - see https://github.com/jakartaee/jaxb-api/releases which lists some breaking changes
to make the test in the project passing:
- update test:
@Test
public void testContextLoading() throws JAXBException {
Map<String, Object> props = new HashMap<>();
props.put(JAXBContext.JAXB_CONTEXT_FACTORY, inner_element_value_objects.impl.JAXBContextFactory.class.getName());
assertNotNull(JAXBContext.newInstance("inner_element_value_objects", new JAXBClassLoader(), props)));
}
- remove the value of the
JAXBContext.JAXB_CONTEXT_FACTORYfrom the options passed to JAXBContext.newInstance methods in custom factory implementation
Thanks for the hint / solution.
The release notes you refer read "drops implementation lookup through jaxb.properties file" – that does not fit with the error in the top post above. And JAXBContext could be somehow inferred from the package like it was in v3 – are there any plans to improve that?