You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by "munishgupta.asr" <mu...@gmail.com> on 2019/05/20 13:40:20 UTC

ClassCastException on same class in Karaf 4.2.2

Hi Team

We upgraded our karaf version to 4.2.2. Then onward we are seeing
ClassCastException on same class while installing a kar file.

The installation of new kar file triggers the activation of other bundle
where code is fetching the some record from database and assigns to some dto
object, there it it is throwing classcastException.

The Sample log snippet
*com.google.common.util.concurrent.UncheckedExecutionException:
java.lang.ClassCastException: com.good.gcs.jsonstore.dto.JsonValue cannot be
cast to com.good.gcs.jsonstore.dto.JsonValue*

From internet resources, the classcastException on same class is because if
it was loaded by 2 different class loaders . 

This behavior not seen when we are using old karaf versions like 3.x. or
4.0.x

Any help here please.

Thanks
Sai



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: ClassCastException on same class in Karaf 4.2.2

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

can you please share the kar ? I will try.

Regards
JB

On 21/05/2019 12:45, munishgupta.asr wrote:
> Hi JB 
> 
> Verified the versions of the both bundles and even kar file which we are
> installing and did not see any discrepancy . All are in same versions. 
> 
> Any other clue please. 
> 
> Thanks 
> Sai
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: ClassCastException on same class in Karaf 4.2.2

Posted by "munishgupta.asr" <mu...@gmail.com>.
Hi JB 

Verified the versions of the both bundles and even kar file which we are
installing and did not see any discrepancy . All are in same versions. 

Any other clue please. 

Thanks 
Sai



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: ClassCastException on same class in Karaf 4.2.2

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Sorry, I meant the Export-Package.

Maybe two bundles export the same package with different version.

Regards
JB

On 20/05/2019 15:55, munishgupta.asr wrote:
> Thanks JB for your quick response. 
> 
> Can you please clarify which version you are referring here ? Is it Bundle
> version ? or any thing ? 
> 
> Regards 
> Sai
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: ClassCastException on same class in Karaf 4.2.2

Posted by "munishgupta.asr" <mu...@gmail.com>.
Thanks JB for your quick response. 

Can you please clarify which version you are referring here ? Is it Bundle
version ? or any thing ? 

Regards 
Sai



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: ClassCastException on same class in Karaf 4.2.2

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

Yes, it's certainly because the class JsonValue is coming from two
different classloaders.

Do you have two bundles providing the same class (maybe in different
version) ?

Regards
JB

On 20/05/2019 15:40, munishgupta.asr wrote:
> Hi Team
> 
> We upgraded our karaf version to 4.2.2. Then onward we are seeing
> ClassCastException on same class while installing a kar file.
> 
> The installation of new kar file triggers the activation of other bundle
> where code is fetching the some record from database and assigns to some dto
> object, there it it is throwing classcastException.
> 
> The Sample log snippet
> *com.google.common.util.concurrent.UncheckedExecutionException:
> java.lang.ClassCastException: com.good.gcs.jsonstore.dto.JsonValue cannot be
> cast to com.good.gcs.jsonstore.dto.JsonValue*
> 
> From internet resources, the classcastException on same class is because if
> it was loaded by 2 different class loaders . 
> 
> This behavior not seen when we are using old karaf versions like 3.x. or
> 4.0.x
> 
> Any help here please.
> 
> Thanks
> Sai
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com