I ran into a similar but possibly opposite problem on karaf trunk.  For me, 
when I deployed a jaxb 2.2/stax 1.2 + geronimo specs for these set of bundles 
in karaf I got no contents to my top level jaxb object, but when I ran with the 
jvm versions jaxb worked properly.  At one point I got a setup where one of the 
two elements inside my top level element was unmarshalled into a java object 
and the other one wasn't.

I haven't figured out what is going on yet, but I do wonder with the 
bootdelegation property set to include com.sun.* how any later sun jaxb 
implementation can be installed as a bundle and work -- I'd expect all the 
classes to be loaded from the vm no matter what you do.

I may well have to actually solve this problem soon so I'm very interested in 
any clues about what is going on.

thanks
david jencks

On Apr 9, 2011, at 4:16 AM, Lindley Andrew wrote:

> 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(newStreamSource((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