Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.RuntimeException: java.lang.ClassNotFoundException for an add-on bundle (Helios) #1546

Closed
kgoderis opened this issue Jun 13, 2023 · 1 comment · Fixed by openhab/openhab-addons#15096

Comments

@kgoderis
Copy link
Contributor

Using the latest SNAPSHOT and doing a feature install openhab-binding-helios the following gets thrown:

2023-06-13 19:53:14.188 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.initialize()' on 'org.openhab.binding.helios.internal.handler.HeliosHandler221@47cbdc8c': java.lang.ClassNotFoundException
java.lang.RuntimeException: java.lang.ClassNotFoundException
	at javax.ws.rs.client.ClientBuilder.newBuilder(ClientBuilder.java:50) ~[?:?]
	at org.openhab.binding.helios.internal.handler.HeliosHandler221.initialize(HeliosHandler221.java:174) ~[?:?]
	at jdk.internal.reflect.GeneratedMethodAccessor93.invoke(Unknown Source) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
	at org.openhab.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:147) ~[?:?]
	at org.openhab.core.internal.common.Invocation.call(Invocation.java:52) ~[?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
	at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.ClassNotFoundException
	at javax.ws.rs.client.ClientFinder.newInstance(ClientFinder.java:120) ~[?:?]

which indicates that javax.ws.rs.client.ClientBuilder can not be found. This is strange, since this is provided by another feature because used by other bindings

The karaf runtime reports the following:

openhab> bundle:info 62

Apache Aries JAX-RS Specification API (62)

openhab> bundle:classes 62 | grep Client
javax/ws/rs/client/Client.class | exported: true
javax/ws/rs/client/ClientFinder.class | exported: true
javax/ws/rs/client/ClientRequestFilter.class | exported: true
javax/ws/rs/client/ClientResponseContext.class | exported: true
javax/ws/rs/client/ClientResponseFilter.class | exported: true
javax/ws/rs/ClientErrorException.class | exported: true
javax/ws/rs/client/ClientBuilder.class | exported: true
javax/ws/rs/client/ClientRequestContext.class | exported: true

and

openhab> bundle:capabilities 62
org.apache.aries.javax.jax.rs-api_1.0.1 [62] provides:
------------------------------------------------------
osgi.wiring.package; javax.ws.rs.client 2.1.0 required by:
   org.apache.cxf.cxf-rt-rs-sse_3.4.5 [69]
   org.apache.cxf.cxf-rt-frontend-jaxrs_3.4.5 [67]
   org.apache.cxf.cxf-rt-rs-client_3.4.5 [68]
   org.osgi.service.jaxrs_1.0.0.201802012106 [227]
   org.apache.aries.jax.rs.whiteboard_2.0.0 [63]
   org.openhab.binding.tesla_4.0.0.202306120408 [275]
   org.openhab.binding.helios_4.0.0.202306131752 [316]

It indicates to me that all is fine

if you now compare this: [316 = the Helios SNAPSHOT-4.0.0 binding]

openhab> bundle:headers 316

openHAB Add-ons :: Bundles :: Helios Binding (316)
--------------------------------------------------
Automatic-Module-Name = org.openhab.binding.helios
Bnd-LastModified = 1686678738174
Build-Jdk = 17.0.7
Built-By = kgoderis
Created-By = 17.0.7 (Azul Systems, Inc.)
Manifest-Version = 1.0
Service-Component = OSGI-INF/org.openhab.binding.helios.internal.HeliosHandlerFactory.xml
Tool = Bnd-6.4.0.202211291949

Bundle-Description = This project contains the official add-ons of openHAB
Bundle-Developers = openhab;email="info@openhab.org";name=openHAB;organization=openHAB;organizationUrl="https://www.openHAB.org"
Bundle-DocURL = https://github.com/openhab/infrastructure/org.openhab.addons.reactor/org.openhab.addons.reactor.bundles/org.openhab.binding.helios
Bundle-License = "Eclipse Public License 2.0";link="https://www.eclipse.org/legal/epl-2.0/"
Bundle-ManifestVersion = 2
Bundle-Name = openHAB Add-ons :: Bundles :: Helios Binding
Bundle-SCM = url="https://github.com/openhab/openhab-addons/org.openhab.addons.reactor.bundles/org.openhab.binding.helios",connection="scm:git:https://github.com/openhab/openhab-addons.git/org.openhab.addons.reactor.bundles/org.openhab.binding.helios",developer-connection="scm:git:https://github.com/openhab/openhab-addons.git/org.openhab.addons.reactor.bundles/org.openhab.binding.helios",tag=HEAD
Bundle-SymbolicName = org.openhab.binding.helios
Bundle-Vendor = openHAB.org
Bundle-Version = 4.0.0.202306131752

Provide-Capability = 
	osgi.service;uses:=org.openhab.core.thing.binding;objectClass:List<String>=org.openhab.core.thing.binding.ThingHandlerFactory
Require-Capability = 
	osgi.extender;filter:=(&(osgi.extender=osgi.component)(version>=1.5.0)(!(version>=2.0.0))),
	osgi.contract;filter:=(&(osgi.contract=JavaJAXRS)(version=2.1.0));osgi.contract=JavaJAXRS,
	osgi.ee;filter:=(&(osgi.ee=JavaSE)(version=17))

Import-Package = 
	org.openhab.core.config.core,
	org.openhab.core.library.types,
	org.openhab.core.thing,
	org.openhab.core.thing.binding,
	org.openhab.core.thing.binding.builder,
	org.openhab.core.thing.type,
	org.openhab.core.types,
	com.google.gson;version="[2.9,3)",
	javax.net.ssl,
	javax.ws.rs,
	javax.ws.rs.client,
	javax.ws.rs.core,
	org.slf4j;version="[1.7,2)"
Private-Package = 
	OH-INF.addon,
	OH-INF.i18n,
	OH-INF.thing,
	org.openhab.binding.helios.internal,
	org.openhab.binding.helios.internal.handler,
	org.openhab.binding.helios.internal.ws.rest

and this : [313 = Helios 3.0.x binding, which happens to work]

openhab> bundle:headers 313

openHAB Add-ons :: Bundles :: Helios Binding (313)
--------------------------------------------------
Automatic-Module-Name = org.openhab.binding.helios
Bnd-LastModified = 1604302958374
Build-Jdk = 11.0.8
Built-By = kgoderis
Created-By = 11.0.8 (Oracle Corporation)
Manifest-Version = 1.0
Service-Component = OSGI-INF/org.openhab.binding.helios.internal.HeliosHandlerFactory.xml
Tool = Bnd-5.1.2.202007211702

Bundle-Description = This project contains the official add-ons of openHAB
Bundle-Developers = openhab;email="info@openhab.org";name=openHAB;organization=openHAB;organizationUrl="https://www.openHAB.org"
Bundle-DocURL = https://github.com/openhab/infrastructure/org.openhab.addons.reactor/org.openhab.addons.reactor.bundles/org.openhab.binding.helios
Bundle-License = "Eclipse Public License 2.0";link="https://www.eclipse.org/legal/epl-2.0/"
Bundle-ManifestVersion = 2
Bundle-Name = openHAB Add-ons :: Bundles :: Helios Binding
Bundle-SCM = url="https://github.com/openhab/openhab-addons/org.openhab.addons.reactor.bundles/org.openhab.binding.helios",connection="scm:git:https://github.com/openhab/openhab-addons.git/org.openhab.addons.reactor.bundles/org.openhab.binding.helios",developer-connection="scm:git:https://github.com/openhab/openhab-addons.git/org.openhab.addons.reactor.bundles/org.openhab.binding.helios",tag=HEAD
Bundle-SymbolicName = org.openhab.binding.helios
Bundle-Vendor = openHAB.org
Bundle-Version = 3.0.0.202011020742

Provide-Capability = 
	osgi.service;uses:=org.openhab.core.thing.binding;objectClass:List<String>=org.openhab.core.thing.binding.ThingHandlerFactory
Require-Capability = 
	**osgi.service;effective:=active;filter:=(objectClass=javax.ws.rs.client.ClientBuilder),**
	osgi.extender;filter:=(&(osgi.extender=osgi.component)(version>=1.4.0)(!(version>=2.0.0))),
	osgi.contract;filter:=(&(osgi.contract=JavaJAXRS)(version=2.1.0));osgi.contract=JavaJAXRS,
	osgi.ee;filter:=(&(osgi.ee=JavaSE)(version=11))

Import-Package = 
	org.openhab.core.config.core,
	org.openhab.core.library.types,
	org.openhab.core.thing,
	org.openhab.core.thing.binding,
	org.openhab.core.thing.binding.builder,
	org.openhab.core.thing.type,
	org.openhab.core.types,
	com.google.gson;version="[2.8,3)",
	javax.net.ssl,
	javax.ws.rs,
	javax.ws.rs.client,
	javax.ws.rs.core,
	org.slf4j;version="[1.7,2)"
Private-Package = 
	OH-INF.binding,
	OH-INF.thing,
	org.openhab.binding.helios.internal,
	org.openhab.binding.helios.internal.handler,
	org.openhab.binding.helios.internal.ws.rest

then the only difference between the 2 is on the Require-Capability, which is effectively missing for the SNAPSHOT-4.x binding.

Why is the output from bundle:headers conflicting with the output of bundle:capabilities 62? for the latter it correctly identifies that the helios binding needs the client, but in the headers of the given bundle it is missing?

What am I missing here?

@kgoderis
Copy link
Contributor Author

Closed by openhab/openhab-addons#15096

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant