ClassCasteException in Websphere 8.5.5.2

I am getting classCasteException in the following expression:

function axxxxx(X resource)
{
    ((SimpleConnectionImpl)resource).somefunction();// getting classcaste exception here
}

      

I checked the resource runtime and found it org.java.SimpleConnectionImpl@ao4d0323

. However, it cannot typecaste.where because SimpleConnectionImpl

it is also in the same package.

Do you have any suggestions? The InstanceOff operator also returns false here. When I do getclass()

, it returns the same class name.

+3


source to share


1 answer


You probably have two versions of the same JAR in your classpath. Make sure that only one version of the JAR containing the SimpleConnectionImpl is in all the dependencies that are included by all JAR artifacts (EAR, WAR, etc.) in the complete application.



More precisely, you only want one copy of any given class under one classloader. Removing duplicate classes for all of your artifacts is an important part of deploying in J2EE environments and reduces the bugs that can sometimes lead to its creation.

0


source







All Articles