OK, I've read all the previous posts and tried seven different ways to Sunday 
to get this to work.  I've seen a fair number of posts with the same problem, 
but none of the recommendations seems to work for me.

I'm trying to unmarshal some XML into java objects.  My code works fine in a 
standalone environment, but when I run it in OSGi I'm getting exceptions.

The line:

           JAXBContext jaxbContext = JAXBContext.newInstance(packageName);     
// this is line 215 in the stacktrace below

Results in the following exception:
javax.xml.bind.JAXBException: Provider 
com.sun.xml.internal.bind.v2.ContextFactory not found - with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
                at 
javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:146)
                at javax.xml.bind.ContextFinder.find(ContextFinder.java:289)
                at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:412)
                at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:375)
                at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:279)
                at Utils.unMarshall(Utils.java:215)
                at 
osgi.controller.JCMSController.publish(JCMSController.java:245)
                at 
osgi.controller.JCMSController.publishTrigger(JCMSController.java:320)
                at osgi.hscb.TcpThread.run(TcpThread.java:107)
                at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: 
com.sun.xml.internal.bind.v2.ContextFactory
                at 
org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:744)
                at 
org.apache.felix.framework.ModuleImpl.access$100(ModuleImpl.java:61)
                at 
org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1656)
                at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
                at 
org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:604)
                at 
org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1487)
                at 
org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:897)
                at 
org.ops4j.pax.swissbox.core.BundleClassLoader.findClass(BundleClassLoader.java:176)
                at 
org.ops4j.pax.swissbox.core.BundleClassLoader.loadClass(BundleClassLoader.java:194)
                at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
                at 
javax.xml.bind.ContextFinder.safeLoadClass(ContextFinder.java:480)
                at 
javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:112)
                ... 9 more

As suggested in many of the posts, I've tried passing in the classloader to the 
newInstance call and it doesn't help.  Based on the classloader I use, I can 
also receive the following exception:


java.lang.RuntimeException: javax.xml.bind.JAXBException:

"xxx.xxxx.xxxx" doesnt contain ObjectFactory.class or jaxb.index


My bundle that contains the xsd's, JAXB compiled objects, and the marshalling 
code uses the following dependency:

        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api-osgi</artifactId>
            <version>2.2</version>
        </dependency>

I'm using Glassfish V3-SNAPSHOT.

Am I missing an import package in my manifest?  Any pointers would be greatly 
appreciated.

Thanks,
Larry

Reply via email to