You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by "Althaus, Volker" <v....@cenit.de> on 2018/12/05 13:15:42 UTC

ClassCastException when calling FeaturesService#refreshFeatures - Duplicate JaxB on classpath

Hi,
I am stuck on a problem with a duplicate jaxb library on the classpath. 

Environment: Karaf 4.2.1, Win 7.

Somewhere in my custom code I call "FeaturesService#refreshFeatures(EnumSet.noneOf(Option.class))". The FeaturesService is injected by a SCR @Reference annotation.

The resulting exception is:
java.lang.ClassCastException: org.apache.karaf.features.internal.model.Capability$JaxbAccessorF_value cannot be cast to com.sun.xml.internal.bind.v2.runtime.reflect.Accessor
org.apache.karaf.features.internal.service.FeaturesProcessingSerializer.(FeaturesProcessingSerializer.java:80)
org.apache.karaf.features.internal.service.FeaturesProcessorImpl.(FeaturesProcessorImpl.java:58)
org.apache.karaf.features.internal.service.FeaturesProcessorImpl.(FeaturesProcessorImpl.java:98)
org.apache.karaf.features.internal.service.FeaturesProcessorImpl.(FeaturesProcessorImpl.java:106)
org.apache.karaf.features.internal.service.FeaturesServiceImpl.refreshFeatures(FeaturesServiceImpl.java:1183)

When I call "feature:refresh" on the console: No exception.

I googled around and found some threads about this and that I may have a duplicate jaxb lib on the classpath and I should remove all obsolete occurrences.
I also found [KARAF-5912] where the jaxb-impl bundle was removed from the "framework" feature. I applied this to my Karaf 4.2.1 and also in all other features of my distribution (Camel e.g.).
I removed it also in the startup.properties.

Same exception again. Then I found another jaxb-impl-2.2.11.jar in the /lib/boot/ folder. If I remove this - it works!

But now my question: Is this the correct way and don't I break something by removing this lib?
And how can I remove it from my custom distribution? The karaf-maven-plugin does not have an option to remove libs which are included in the standard Karaf distribution. I didn't know any Maven phases where to hook a file delete after the karaf-maven-plugin did it's work (unless unpacking the zip, delete the file and re-package the stuff).

Any ideas?


TIA & Regards
Volker Althaus


CENIT AG, Industriestrasse 52-54, 70565 Stuttgart, Tel.: +49 711 7825-30, Fax: +49 711 7825-4000, Internet: www.cenit.com
Geschaeftsstellen (Branch Offices): Berlin, Frankfurt, Hamburg, Hannover, Muenchen, Oelsnitz, Ratingen, Saarbruecken
Vorstandsmitglieder (Members of the Board): Kurt Bengel  (CEO), Matthias Schmidt  (CFO)
Aufsichtsratsmitglieder (Supervisory Board Members): Prof. Dr. Oliver Riedel (Vorsitzender des Aufsichtsrats / Chairman of the Supervisory Board), Stephan Gier, Ricardo Malta
Bankverbindungen (Bank Accounts):
Deutsche Bank (BLZ 600 700 70) Kto. 1661 040 IBAN : DE85 6007 0070 0166 1040 00 SWIFT-CODE : DEUTDESS,
Commerzbank (BLZ 600 400 71) Kto. 532 015 500 IBAN : DE83 6004 0071 0532 0155 00 SWIFT-Code : COBADEFF600,
Registergericht (Registry court): Amtsgericht Stuttgart
Handelsregister (Commercial Register): HRB Nr. 19117
Umsatzsteuer (VAT) ID: DE 147 862 777


Re: ClassCastException when calling FeaturesService#refreshFeatures - Duplicate JaxB on classpath

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Volker,

it's a bug in 4.2.1, already fixed in 4.2.2-SNAPSHOT (it will be 
included in 4.2.2).

Regards
JB

On 05/12/2018 14:15, Althaus, Volker wrote:
> Hi,
> I am stuck on a problem with a duplicate jaxb library on the classpath.
> 
> Environment: Karaf 4.2.1, Win 7.
> 
> Somewhere in my custom code I call "FeaturesService#refreshFeatures(EnumSet.noneOf(Option.class))". The FeaturesService is injected by a SCR @Reference annotation.
> 
> The resulting exception is:
> java.lang.ClassCastException: org.apache.karaf.features.internal.model.Capability$JaxbAccessorF_value cannot be cast to com.sun.xml.internal.bind.v2.runtime.reflect.Accessor
> org.apache.karaf.features.internal.service.FeaturesProcessingSerializer.(FeaturesProcessingSerializer.java:80)
> org.apache.karaf.features.internal.service.FeaturesProcessorImpl.(FeaturesProcessorImpl.java:58)
> org.apache.karaf.features.internal.service.FeaturesProcessorImpl.(FeaturesProcessorImpl.java:98)
> org.apache.karaf.features.internal.service.FeaturesProcessorImpl.(FeaturesProcessorImpl.java:106)
> org.apache.karaf.features.internal.service.FeaturesServiceImpl.refreshFeatures(FeaturesServiceImpl.java:1183)
> 
> When I call "feature:refresh" on the console: No exception.
> 
> I googled around and found some threads about this and that I may have a duplicate jaxb lib on the classpath and I should remove all obsolete occurrences.
> I also found [KARAF-5912] where the jaxb-impl bundle was removed from the "framework" feature. I applied this to my Karaf 4.2.1 and also in all other features of my distribution (Camel e.g.).
> I removed it also in the startup.properties.
> 
> Same exception again. Then I found another jaxb-impl-2.2.11.jar in the /lib/boot/ folder. If I remove this - it works!
> 
> But now my question: Is this the correct way and don't I break something by removing this lib?
> And how can I remove it from my custom distribution? The karaf-maven-plugin does not have an option to remove libs which are included in the standard Karaf distribution. I didn't know any Maven phases where to hook a file delete after the karaf-maven-plugin did it's work (unless unpacking the zip, delete the file and re-package the stuff).
> 
> Any ideas?
> 
> 
> TIA & Regards
> Volker Althaus
> 
> 
> CENIT AG, Industriestrasse 52-54, 70565 Stuttgart, Tel.: +49 711 7825-30, Fax: +49 711 7825-4000, Internet: www.cenit.com
> Geschaeftsstellen (Branch Offices): Berlin, Frankfurt, Hamburg, Hannover, Muenchen, Oelsnitz, Ratingen, Saarbruecken
> Vorstandsmitglieder (Members of the Board): Kurt Bengel  (CEO), Matthias Schmidt  (CFO)
> Aufsichtsratsmitglieder (Supervisory Board Members): Prof. Dr. Oliver Riedel (Vorsitzender des Aufsichtsrats / Chairman of the Supervisory Board), Stephan Gier, Ricardo Malta
> Bankverbindungen (Bank Accounts):
> Deutsche Bank (BLZ 600 700 70) Kto. 1661 040 IBAN : DE85 6007 0070 0166 1040 00 SWIFT-CODE : DEUTDESS,
> Commerzbank (BLZ 600 400 71) Kto. 532 015 500 IBAN : DE83 6004 0071 0532 0155 00 SWIFT-Code : COBADEFF600,
> Registergericht (Registry court): Amtsgericht Stuttgart
> Handelsregister (Commercial Register): HRB Nr. 19117
> Umsatzsteuer (VAT) ID: DE 147 862 777
> 

RE: ClassCastException when calling FeaturesService#refreshFeatures - Duplicate JaxB on classpath

Posted by "Siano, Stephan" <st...@sap.com>.
Hi Volker,

Yes, this is a bug in 4.2.1 with Java 8 introduced with some functionality for Java 11. On Java 8 the jaxb is coming from the JDK (therefore you get these duplicate implementations with the library in the boot folder, so removing the library there is the correct thing to do.

This will be fixed for 4.2.2 (there jaxb is moved to some other folder which is not used in the Java 8 classpath).

Best regards
Stephan

-----Original Message-----
From: Althaus, Volker <v....@cenit.de> 
Sent: Mittwoch, 5. Dezember 2018 14:16
To: user@karaf.apache.org
Subject: ClassCastException when calling FeaturesService#refreshFeatures - Duplicate JaxB on classpath

Hi,
I am stuck on a problem with a duplicate jaxb library on the classpath. 

Environment: Karaf 4.2.1, Win 7.

Somewhere in my custom code I call "FeaturesService#refreshFeatures(EnumSet.noneOf(Option.class))". The FeaturesService is injected by a SCR @Reference annotation.

The resulting exception is:
java.lang.ClassCastException: org.apache.karaf.features.internal.model.Capability$JaxbAccessorF_value cannot be cast to com.sun.xml.internal.bind.v2.runtime.reflect.Accessor
org.apache.karaf.features.internal.service.FeaturesProcessingSerializer.(FeaturesProcessingSerializer.java:80)
org.apache.karaf.features.internal.service.FeaturesProcessorImpl.(FeaturesProcessorImpl.java:58)
org.apache.karaf.features.internal.service.FeaturesProcessorImpl.(FeaturesProcessorImpl.java:98)
org.apache.karaf.features.internal.service.FeaturesProcessorImpl.(FeaturesProcessorImpl.java:106)
org.apache.karaf.features.internal.service.FeaturesServiceImpl.refreshFeatures(FeaturesServiceImpl.java:1183)

When I call "feature:refresh" on the console: No exception.

I googled around and found some threads about this and that I may have a duplicate jaxb lib on the classpath and I should remove all obsolete occurrences.
I also found [KARAF-5912] where the jaxb-impl bundle was removed from the "framework" feature. I applied this to my Karaf 4.2.1 and also in all other features of my distribution (Camel e.g.).
I removed it also in the startup.properties.

Same exception again. Then I found another jaxb-impl-2.2.11.jar in the /lib/boot/ folder. If I remove this - it works!

But now my question: Is this the correct way and don't I break something by removing this lib?
And how can I remove it from my custom distribution? The karaf-maven-plugin does not have an option to remove libs which are included in the standard Karaf distribution. I didn't know any Maven phases where to hook a file delete after the karaf-maven-plugin did it's work (unless unpacking the zip, delete the file and re-package the stuff).

Any ideas?


TIA & Regards
Volker Althaus


CENIT AG, Industriestrasse 52-54, 70565 Stuttgart, Tel.: +49 711 7825-30, Fax: +49 711 7825-4000, Internet: www.cenit.com
Geschaeftsstellen (Branch Offices): Berlin, Frankfurt, Hamburg, Hannover, Muenchen, Oelsnitz, Ratingen, Saarbruecken
Vorstandsmitglieder (Members of the Board): Kurt Bengel  (CEO), Matthias Schmidt  (CFO)
Aufsichtsratsmitglieder (Supervisory Board Members): Prof. Dr. Oliver Riedel (Vorsitzender des Aufsichtsrats / Chairman of the Supervisory Board), Stephan Gier, Ricardo Malta
Bankverbindungen (Bank Accounts):
Deutsche Bank (BLZ 600 700 70) Kto. 1661 040 IBAN : DE85 6007 0070 0166 1040 00 SWIFT-CODE : DEUTDESS,
Commerzbank (BLZ 600 400 71) Kto. 532 015 500 IBAN : DE83 6004 0071 0532 0155 00 SWIFT-Code : COBADEFF600,
Registergericht (Registry court): Amtsgericht Stuttgart
Handelsregister (Commercial Register): HRB Nr. 19117
Umsatzsteuer (VAT) ID: DE 147 862 777