I posted this problem over on the Glassfish forum, and got the following from 
Sahoo.  I implemented the workaround and it works great.

======================================================================

I have actually filed a bug for this. See [1]. Vote for it please. I don't know 
if there is any better way to solve it, but I faced it for one of my GlassFish 
extension bundles and I worked around it like this:

    import org.glassfish.internal.api.Globals;
    import org.glassfish.internal.api.ClassLoaderHierarchy;
    
    ...

    private JAXBContext getJAXBContext() throws JAXBException {
        // We need to set context class loader to be CommonClassLoader, 
otherwise our stupid JAXB implementation
        // won't be able to locate the default JAXB context factory class.
        final Thread thread = Thread.currentThread();
        ClassLoader oldCL = thread.getContextClassLoader();
        try {
            ClassLoader ccl = 
Globals.get(ClassLoaderHierarchy.class).getCommonClassLoader();
            thread.setContextClassLoader(ccl);
            JAXBContext jc = JAXBContext.newInstance(ObjectFactory.class);
        return jc;
        } finally {
            thread.setContextClassLoader(oldCL);
        }
    }

You will have to add the following dependency to compile though:

       <dependency>
            <groupId>org.glassfish.common</groupId>
            <artifactId>internal-api</artifactId>
            <version>${project.version}</version>
        </dependency>

I don't think you can apply this work around in your code - it has too much 
dependency on glassfish internals. 

Thanks,
Sahoo

[1] https://glassfish.dev.java.net/issues/show_bug.cgi?id=11748

Larry

> -----Original Message-----
> From: Andrea Turbati [mailto:[email protected]]
> Sent: Monday, June 07, 2010 6:06 AM
> To: [email protected]
> Subject: ObjectFactory.class or jaxb.index
> 
> Hi,
> I've presented this problem in another discussion, which started from a
> totally different one, so I've decided to open a new discussion with the
> hope to solve it.
> 
> In my bundle I'm trying to use a a library which it's using a webservice
> (the OKKAM webservice).
> 
> When the bundle invoke a class from the library I have the following
> error:
> 
> java.lang.RuntimeException: javax.xml.bind.JAXBException:
> "org.okkam.client.data" doesnt contain ObjectFactory.class or jaxb.index
>      at org.okkam.client.util.XMLEntityConverter.init(Unknown Source)
>      at org.okkam.client.util.XMLEntityConverter.xmlToEntity(Unknown
> Source)
>      at
> it.uniroma2.art.maskkot.osgi.service.Maskkot.inquireOkkamForIds(Maskkot.
> java:130)
> 
> 
> Doing a search on internet I've found this site:
> http://stackoverflow.com/questions/1043109/why-cant-jaxb-find-my-jaxb-
> index-when-running-inside-apache-felix
> (It appears to be a similar problem)
> 
> I've checked in the jar library which is inside my bundle and I've found
> that in the package org.okkam.client.data the file ObjectFactory.class
> exixts (but not the file jaxb.index), so I really don't understand the
> meaning of that error.
> 
> My application is a bit particular, because the main java application
> (the one with the Felix instance) is run from inside Firefox as an
> estension and my bundle is an extension to both Firefox and to Felix. So
> the main java application is not able to see the normal classpath, but I
> have to explicitely list all the jar library, so maybe this is part of
> the problem.
> 
> Thanks
> 
> Andrea
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> 
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 9.0.819 / Virus Database: 271.1.1/2899 - Release Date: 06/07/10
> 02:35:00

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to