It is there, in the package, that it should be indexed. However, when I call
JAXBContext jc = JAXBContext.newInstance("my.package.name");
I get a JAXBException saying that
"my.package.name" does not contain ObjectFactory.class or jaxb.index
although it contains both.
What works, but not exactly what I want
JAXBContext jc = JAXBContext.newInstance(my.package.name.SomeClass.class);
This question from other people appears on some mailing lists and forums, but doesn't seem to get any answers.
I run this on OpenJDK 6, so I got the source packages and stepped back from my debugger in the library. It starts by searching for jaxb.properties, then searches for system properties and does not find them, it tries to create a default context using com.sun.internal.xml.bind.v2.ContextFactory. An Exception is ContextFactor.createContext(String ClassLoader, Map) (inside ContextFactor.createContext(String ClassLoader, Map) ), but I do not see what happens because there is no source.
Eta
Judging by the source code of ContentFactory, I found here , this is probably the part of the code that is not working properly:
private static List<Class> loadIndexedClasses(String pkg, ClassLoader classLoader) throws IOException, JAXBException { final String resource = pkg.replace('.', '/') + "/jaxb.index"; final InputStream resourceAsStream = classLoader.getResourceAsStream(resource); if (resourceAsStream == null) { return null; }
From my previous experience , I assume that this is due to mechanisms for loading classes from the OSGi container in which it works. Unfortunately, I'm still a little out of my depth.
java jaxb osgi apache-felix
Hanno Fietz Jun 25 '09 at 10:21 2009-06-25 10:21
source share