Skip to main content

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

Priyanka,
  
   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) {
                log.error(e.getMessage(),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?

Link


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

Hi,

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?

Thanx
Priyanka


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



Back to the top