javawebspherewebsphere-9

Java.lang.LinkageError for Java ear-file in Websphere 9


I got this error in Websphere 9 for a Java application deployed as an EAR-file when I try calling one of my web services.

Caused by: java.lang.LinkageError: ClassCastException: attempting to castbundleresource://265.fwk-1702970980/javax/ws/rs/client/ClientBuilder.class to wsjar:file:/opt/app/was/WebSphere/AppServer/profiles/prctstwas01/installedApps/lsp7288cNode01Cell/OurApplicaton.ear/OurApplicationWeb.war/WEB-INF/lib/integration-commons

I understand what this error is and I solved it by setting the classloader for the war-file in my ear-file to parent first, if anyone searching this error wonder how to solve it. But I don't get where the first version of the class 65.fwk-1702970980/javax/ws/rs/client/ClientBuilder.class comes from.

Does anyone know what bundle resource://265.fwk-1702970980 is referring to? I guess it is also a version of the class bundled with my war-file? It doen't look like it comes from the applicaton server.


Solution

  • bundleresource URLs come from OSGi class loaders. In the case of WebSphere, that usually means they were provided by the server, as basically the whole server runtime runs within OSGi. 265.fwk-1702970980 is the internal name of the bundle - if you list the bundles using the OSGi console, the JAX-RS API bundle is probably bundle number 265.