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

[sleepiq] ClassNotFoundException when communicating with CloudIQ service #11696

Closed
mhilbush opened this issue Dec 4, 2021 · 6 comments · Fixed by #11700
Closed

[sleepiq] ClassNotFoundException when communicating with CloudIQ service #11696

mhilbush opened this issue Dec 4, 2021 · 6 comments · Fixed by #11700
Assignees
Labels
bug An unexpected problem or unintended behavior of an add-on

Comments

@mhilbush
Copy link
Contributor

mhilbush commented Dec 4, 2021

I'm seeing this error when the binding attempts to authenticate with the CloudIQ service. It's failing on the ClientBuilder class.

Looks like a similar problem to the one @J-N-K fixed in the hdpowerview and neeo bindings.
#9224
#9006

2021-12-04 07:01:58.850 [DEBUG] [eepiq.internal.SleepIQHandlerFactory] - Creating SleepIQ cloud thing handler
2021-12-04 07:01:58.851 [DEBUG] [eepiq.internal.SleepIQHandlerFactory] - Registering bed discovery service
2021-12-04 07:01:58.865 [DEBUG] [internal.handler.SleepIQCloudHandler] - Configuring bed status cache
2021-12-04 07:01:58.866 [DEBUG] [internal.handler.SleepIQCloudHandler] - Reading SleepIQ cloud binding configuration
2021-12-04 07:01:58.867 [DEBUG] [internal.handler.SleepIQCloudHandler] - Creating SleepIQ client
2021-12-04 07:01:58.868 [DEBUG] [internal.handler.SleepIQCloudHandler] - Authenticating at the SleepIQ cloud service
2021-12-04 07:01:58.869 [DEBUG] [internal.handler.SleepIQCloudHandler] - Unexpected error while communicating with SleepIQ cloud
java.lang.RuntimeException: java.lang.ClassNotFoundException
	at javax.ws.rs.client.ClientBuilder.newBuilder(ClientBuilder.java:50) ~[bundleFile:?]
	at org.openhab.binding.sleepiq.api.impl.SleepIQImpl.createClient(SleepIQImpl.java:233) ~[bundleFile:?]
	at org.openhab.binding.sleepiq.api.impl.AbstractClient.getClient(AbstractClient.java:35) ~[bundleFile:?]
	at org.openhab.binding.sleepiq.api.impl.SleepIQImpl.login(SleepIQImpl.java:76) ~[bundleFile:?]
	at org.openhab.binding.sleepiq.internal.handler.SleepIQCloudHandler.createCloudConnection(SleepIQCloudHandler.java:115) ~[bundleFile:?]
	at org.openhab.binding.sleepiq.internal.handler.SleepIQCloudHandler.initialize(SleepIQCloudHandler.java:81) [bundleFile:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
	at org.openhab.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:154) [bundleFile:?]
	at org.openhab.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:829) [?:?]
Caused by: java.lang.ClassNotFoundException
	at javax.ws.rs.client.ClientFinder.newInstance(ClientFinder.java:120) ~[bundleFile:?]
	at javax.ws.rs.client.ClientFinder.find(ClientFinder.java:96) ~[bundleFile:?]
	at javax.ws.rs.client.ClientBuilder.newBuilder(ClientBuilder.java:44) ~[bundleFile:?]
	... 15 more
Caused by: java.lang.InstantiationException
	at jdk.internal.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48) ~[?:?]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:490) ~[?:?]
	at java.lang.Class.newInstance(Class.java:584) ~[?:?]
	at javax.ws.rs.client.ClientFinder.newInstance(ClientFinder.java:116) ~[bundleFile:?]
	at javax.ws.rs.client.ClientFinder.find(ClientFinder.java:96) ~[bundleFile:?]
	at javax.ws.rs.client.ClientBuilder.newBuilder(ClientBuilder.java:44) ~[bundleFile:?]
	... 15 more
@mhilbush mhilbush added the bug An unexpected problem or unintended behavior of an add-on label Dec 4, 2021
@mhilbush
Copy link
Contributor Author

mhilbush commented Dec 4, 2021

I'd have a go at fixing this, but I don't know how to tweak Eclipse so that it can deal with his 3rdparty API source code here.
https://github.com/openhab/openhab-addons/tree/main/bundles/org.openhab.binding.sleepiq/src/3rdparty

In Eclipse, all those API classes show as unresolved in the binding classes (such as SleepIQCloudHandler.java). And, as soon as I use Eclipse to edit a source file that references any of those API classes, the binding no longer builds in Maven.

@cweitkamp or @wborn Do you know what I need to do?

@wborn
Copy link
Member

wborn commented Dec 4, 2021

If you use the openHAB Eclipse config they should be automatically added to the build path when importing such projects based on the build-helper-maven-plugin config in the POM. In Eclipse you need to have the buildhelper m2e plugin installed for that which was added in: openhab/openhab-distro#1259

You can also add the folders manually to the "Java Build Path" by editing the project properties:

Screenshot from 2021-12-04 14-55-40

That results in a .classpath file like this:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="src" output="target/classes" path="src/main/java">
		<attributes>
			<attribute name="optional" value="true"/>
			<attribute name="maven.pomderived" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="src" output="target/classes" path="src/3rdparty/java">
		<attributes>
			<attribute name="optional" value="true"/>
			<attribute name="maven.pomderived" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
		<attributes>
			<attribute name="maven.pomderived" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="src" output="target/test-classes" path="src/test/java">
		<attributes>
			<attribute name="optional" value="true"/>
			<attribute name="maven.pomderived" value="true"/>
			<attribute name="test" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="src" output="target/test-classes" path="src/3rdparty/test">
		<attributes>
			<attribute name="optional" value="true"/>
			<attribute name="maven.pomderived" value="true"/>
			<attribute name="test" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
		<attributes>
			<attribute name="maven.pomderived" value="true"/>
			<attribute name="test" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
		<attributes>
			<attribute name="maven.pomderived" value="true"/>
			<attribute name="annotationpath" value="target/dependency"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
		<attributes>
			<attribute name="maven.pomderived" value="true"/>
			<attribute name="annotationpath" value="target/dependency"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="output" path="target/classes"/>
</classpath>

@mhilbush
Copy link
Contributor Author

mhilbush commented Dec 4, 2021

Thanks @wborn!

My Eclipse install is pretty old (about a year, I think), so I suspect I don't have that plug-in. I'll see if I can install that plugin.

@mhilbush
Copy link
Contributor Author

mhilbush commented Dec 4, 2021

I got the plug-in installed. But, I still ended up having to hand-edit the classpath. Thanks for posting that - worked perfectly!

@mhilbush mhilbush self-assigned this Dec 4, 2021
@wborn
Copy link
Member

wborn commented Dec 4, 2021

Most likely you also need to remove plugin from being ignored in the Maven plugin lifecycle execution.

You can edit that using:

Preferences -> Maven -> Lifecycle Mapping -> Open workspace lifecycle mappings metadata

Then remove the <pluginExecution> section like in the PR and save the file.

@mhilbush
Copy link
Contributor Author

mhilbush commented Dec 4, 2021

Good catch. Thank you, Sir!

wborn pushed a commit that referenced this issue Dec 5, 2021
NickWaterton pushed a commit to NickWaterton/openhab-addons that referenced this issue Dec 30, 2021
mischmidt83 pushed a commit to mischmidt83/openhab-addons that referenced this issue Jan 9, 2022
nemerdaud pushed a commit to nemerdaud/openhab-addons that referenced this issue Jan 28, 2022
marcfischerboschio pushed a commit to bosch-io/openhab-addons that referenced this issue May 5, 2022
andan67 pushed a commit to andan67/openhab-addons that referenced this issue Nov 6, 2022
andrasU pushed a commit to andrasU/openhab-addons that referenced this issue Nov 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants