I have run into a classcastexception that I am unable to solve. In the helios binding we use javax.ws.rs.Client, which is provided by the runtime (cfr output from “bundle:capabilities”):
…
javax.ws.rs-api_2.0.1 [35] provides:
…
osgi.wiring.package; javax.ws.rs.client 2.0.1 required by:
org.glassfish.jersey.core.jersey-server_2.22.2 [126]
org.glassfish.jersey.core.jersey-client_2.22.2 [124]
org.glassfish.jersey.core.jersey-common_2.22.2 [125]
org.glassfish.jersey.media.jersey-media-sse_2.22.2 [128]
org.openhab.binding.helios_2.5.10.202010140401 [287]
…
However, when the helios bundle is running, and when a call is made to javax.ws.rs.client.ClientBuilder(), I do get the following error
Exception occurred while initializing handler of thing 'helios:ipvario221:gate': ClassCastException: attempting to castbundleresource://35.fwk1058650291/javax/ws/rs/client/ClientBuilder.class to bundleresource://35.fwk1058650291/javax/ws/rs/client/ClientBuilder.class
java.lang.LinkageError: ClassCastException: attempting to castbundleresource://35.fwk1058650291/javax/ws/rs/client/ClientBuilder.class to bundleresource://35.fwk1058650291/javax/ws/rs/client/ClientBuilder.class
at javax.ws.rs.client.ClientBuilder.newBuilder(ClientBuilder.java:97) ~[?:?]
at org.openhab.binding.helios.internal.handler.HeliosHandler221.initialize(HeliosHandler221.java:173) ~[?:?]
at jdk.internal.reflect.GeneratedMethodAccessor102.invoke(Unknown Source) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:834) [?:?]
What surprises me is that class being referenced (35.fwk1058650291) is the same. If it would be different then I could imagine that another bundle is exporting a javax.ws.rs provider, but is not the case
When I beef up the POM and feature.xml to include Glassfish directly, e.g.
>
For anyone encountering the same problem, it is linked to the kar cache being rebuilt (after being wiped out), and so, in my case the problem went away “automagically”