I've got a problem using JAXB unmarshalling within Karaf 2.1.0. I've got 
several JAXB annotated elements within the my.foo package along with e.g. 
package-info.java, ObjectFactory.java. They have been around for quite some 
time. However as I'm now porting this application to osgi and karaf I'm having 
problems unmarshalling.

The following JUnit test works perfectly as stand-alone - however when I try to 
execute the same calls from within a bundle on karaf I fail.
root.getValue() returns a my.foo.MyRootElement object however with it's fields 
s.getVersion==null and s.getDateCreated==null.
I already stepped in with the debugger and the JAXBContext instance contains 
the same references as within the standalone-JUnit test.

private static JAXBContext jc;
      private File fSigFile;

      @Before
      public void init() {
            fSigFile = new File("C:/TestFile.xml");
            try {
                  jc = JAXBContext.newInstance(my.foo.MyRootElementType.class);

            } catch (JAXBException e) {}
      }

      @Test
      public void testUnmarshalling (){
            try {
                  Assert.assertTrue(fSigFile.canRead());
                  JAXBElement<my.foo.MyRootElementType> root = 
jc.createUnmarshaller().unmarshal(new 
StreamSource((fSigFile).toURL().openStream()),my.foo.MyRootElementType.class);
                  my.foo.MyRootElement s = root.getValue();
                  Assert.assertNotNull(s);
                  Assert.assertNotNull(s.getVersion());
Assert.assertNotNull(s.getDateCreated());
            } catch (Exception e) {
                  Assert.assertTrue(false);
            }
    }

I haven't installed a JAXB impl bundle on karaf. The following system classes 
are used for parsing
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector
com.sun.org.apache.xerces.internal.parsers.XML11Configuration

I'm using the following karaf configuration:
org.osgi.framework.bootdelegation=sun.*,com.sun.*,javax.transaction,javax.transaction.*
org.osgi.framework.executionenvironment=J2SE-1.5,J2SE-1.4,J2SE-1.3

Thanks for your hints,
Kr Andrew

Reply via email to