[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] Jaxb and Osgi

EclipseLink MOXy provides JAXB for OSGi.  The bundles are available on the EclipseLink Downloads page.   You'll want the OSGi bundles distribution. 

Note that in JAXB  you can create a context passing a classloader.  This will be necessary in OSGi for the JAXB implementation to see your domain classes.  If you need any help you can post to the eclipselink-users mailing list or on the EclipseLink newsgroup.

Hope this helps,


林恺 wrote:
   I have  done things like you so I will talk about what I have done here.
   I simply made a JAXB bundle myself, which include those jars I got from the JAXB official site -- activation.jar, jaxb-api.jar, jaxb-impl.jar and jsr173_1.0_api.jar. I put them in a bundle and export their packages in the bundle's MANIFEST.MF Export-Package header. After this, I got a jaxb bundle and other bundle using JAXB api should Import these packages.

Other things are just like you. I put the model classes generated from xsds by jaxb in a bundle. And put the
marshal/unmarshall in another bundle. The marshal/unmarshall bundle imports package from the model bundle and JAXB bundle, and then have the following code to create a marshal/unmarshall to serialize/deserialize the model object.

     if(unmarshaller == null){
            try {
                JAXBContext jc = JAXBContext.newInstance(Model.class);
                unmarshaller = jc.createUnmarshaller();
                log.debug("create unmarshaller for Model parser");
            } catch (JAXBException e) {

   Note that if a use I use Model.class as the argument of the
JAXBContext.newInstance() method. That I have try if I use a string -- "some.package.Model" instead, it will cause a JAXB exception. I don't know exactly why ? But I guess it is related with OSGi bundle's class loader.

   Anyone who have other solutions?


On Wed, Apr 15, 2009 at 5:49 AM, Mitra, Priyanka <priyanka.mitra@xxxxxxxxxx> wrote:


I am running into classloader issues in the equinox/osgi framework while using Jaxb. I have a jar that contains classes generated from xsds. User class (request) is getting created in plugin A which I need to marshal/unmarshall in plugin B which makes a data access call to the backend and returns a response and unmarshalls it to response user object. I ran into Linkage errors. I know why that happens. Jaxb API looks for Jaxb service provider and user classes in that bundle only.

I came across "DynamicJava website" which resolves this problem. http://www.dynamicjava.org/projects/jsr-api/jaxb-osgi
I tried to download all the jars, org.dynamicjava.jsr.jaxb_api, org.dynamicjava.jsr.jpa_api, org.dynamicjava.jsr.stax_api, germino.jar and jaxb-impl.jar, but still couldn’t get it to work. Has anyone tried to use DynamicJava or any solution to get Jaxb working with osgi?


equinox-dev mailing list

_______________________________________________ equinox-dev mailing list equinox-dev@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/equinox-dev

Shaun Smith | Principal Product Manager
Phone: +19055023094
Oracle Server Technologies, Oracle TopLink
ORACLE Canada | 110 Matheson Boulevard West, Suite 100, Mississauga, Ontario | L5R 3P4

Green Oracle Oracle is committed to developing practices and products that help protect the environment

GIF image

GIF image