Hello,

This ClassCastException normally means you have two jaxb-impl bundles(with 
different version) installed in the Karaf container.

Could you please double check it?

You can use Karaf command 
package:exports |grep com.sun.xml.bind

And paste what the output you get here

Thanks!
-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat



> On Sep 10, 2018, at 10:26 PM, Lukasz Lech <[email protected]> wrote:
> 
> Hello,
>  
> After finding out that Karaf 4.2.1 includes Eclipselink version with 
> PostgreSQL Bug Fix (https://bugs.eclipse.org/bugs/show_bug.cgi?id=522408 
> <https://bugs.eclipse.org/bugs/show_bug.cgi?id=522408>) I’ve tested it with 
> my code.
>  
> But another library has backfired, and I feel helpless about finding out what 
> is going on.
>  
> I’m using JAXB to deserialize XML. I have 2 bundles, which have effectively 
> the same code for deserializing XML from the same schema (some configuration 
> data). In one of the bundles, everything works fine, in another one I get the 
> exception:
>  
> JAXBContext.newInstance(targetClass): 
>  
> Caused by: java.lang.ClassCastException: 
> com.example.MyType$JaxbAccessorF_value cannot be cast to 
> com.sun.xml.internal.bind.v2.runtime.reflect.Accessor
>                 at 
> com.sun.xml.internal.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory.instanciate(OptimizedAccessorFactory.java:190)
>  ~[?:?]
>                 at 
> com.sun.xml.internal.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory.get(OptimizedAccessorFactory.java:179)
>  ~[?:?]
>                 at 
> com.sun.xml.internal.bind.v2.runtime.reflect.Accessor$FieldReflection.optimize(Accessor.java:271)
>  ~[?:?]
>                 at 
> com.sun.xml.internal.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.<init>(TransducedAccessor.java:220)
>  ~[?:?]
>                 at 
> com.sun.xml.internal.bind.v2.runtime.reflect.TransducedAccessor.get(TransducedAccessor.java:160)
>  ~[?:?]
>                 at 
> com.sun.xml.internal.bind.v2.model.impl.RuntimeClassInfoImpl.calcTransducer(RuntimeClassInfoImpl.java:230)
>  ~[?:?]
>                 at 
> com.sun.xml.internal.bind.v2.model.impl.RuntimeClassInfoImpl.getTransducer(RuntimeClassInfoImpl.java:204)
>  ~[?:?]
>                 at 
> com.sun.xml.internal.bind.v2.model.impl.RuntimeClassInfoImpl.link(RuntimeClassInfoImpl.java:181)
>  ~[?:?]
>                 at 
> com.sun.xml.internal.bind.v2.model.impl.ModelBuilder.link(ModelBuilder.java:439)
>  ~[?:?]
>                 at 
> com.sun.xml.internal.bind.v2.model.impl.RuntimeModelBuilder.link(RuntimeModelBuilder.java:118)
>  ~[?:?]
>                 at 
> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:443)
>  ~[?:?]
>                 at 
> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:277)
>  ~[?:?]
>                 at 
> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:124)
>  ~[?:?]
>                 at 
> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1123)
>  ~[?:?]
>                 at 
> com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:147)
>  ~[?:?]
>                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native 
> Method) ~[?:?]
>                 at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
> ~[?:?]
>                 at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>  ~[?:?]
>                 at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
>                 at 
> javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:247) ~[?:?]
>                 at 
> javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:234) ~[?:?]
>                 at javax.xml.bind.ContextFinder.find(ContextFinder.java:462) 
> ~[?:?]
>                 at 
> javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641) ~[?:?]
>                 at 
> javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584) ~[?:?]
>  
> I don’t see any substantial difference between those 2 bundles. They have 
> other config files, but the same code parsing them. They use similar package 
> imports etc.
>  
> However, one of them always starts, the other one not.
>  
> How to start debugging that issue? Have you experienced similar behavior or 
> have hints, what can cause them?
>  
> The previous version, in that everything was working stable, was Karaf 4.1.3
>  
> Best regards,
> Lukasz Lech 

Reply via email to