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

[tesla] Failed to find JAX-RS Client #7775

Closed
kaikreuzer opened this issue May 24, 2020 · 11 comments · Fixed by #7789
Closed

[tesla] Failed to find JAX-RS Client #7775

kaikreuzer opened this issue May 24, 2020 · 11 comments · Fixed by #7789
Labels
bug An unexpected problem or unintended behavior of an add-on

Comments

@kaikreuzer
Copy link
Member

Trying the tesla binding on openHAB 3, it fails on startup with this message:

16:15:44.327 [ERROR] [.core.thing.internal.ThingManagerImpl] - Exception occurred while calling thing handler factory 'org.openhab.binding.tesla.internal.TeslaHandlerFactory@55172f95': java.lang.ClassNotFoundException
java.lang.RuntimeException: java.lang.ClassNotFoundException
        at javax.ws.rs.client.ClientBuilder.newBuilder(ClientBuilder.java:50) ~[?:?]
        at javax.ws.rs.client.ClientBuilder.newClient(ClientBuilder.java:55) ~[?:?]
        at org.openhab.binding.tesla.internal.handler.TeslaAccountHandler.<init>(TeslaAccountHandler.java:89) ~[?:?]
        at org.openhab.binding.tesla.internal.TeslaHandlerFactory.createHandler(TeslaHandlerFactory.java:56) ~[?:?]
        at org.openhab.core.thing.binding.BaseThingHandlerFactory.registerHandler(BaseThingHandlerFactory.java:126) ~[bundleFile:?]
        at org.openhab.core.thing.internal.ThingManagerImpl.doRegisterHandler(ThingManagerImpl.java:632) [bundleFile:?]
        at org.openhab.core.thing.internal.ThingManagerImpl.registerHandler(ThingManagerImpl.java:609) [bundleFile:?]
        at org.openhab.core.thing.internal.ThingManagerImpl.registerAndInitializeHandler(ThingManagerImpl.java:1078) [bundleFile:?]
        at org.openhab.core.thing.internal.ThingManagerImpl.lambda$10(ThingManagerImpl.java:1060) [bundleFile:?]
        at java.util.concurrent.CopyOnWriteArrayList.forEach(CopyOnWriteArrayList.java:803) [?:?]
        at java.util.concurrent.CopyOnWriteArraySet.forEach(CopyOnWriteArraySet.java:425) [?:?]
        at org.openhab.core.thing.internal.ThingManagerImpl.lambda$9(ThingManagerImpl.java:1057) [bundleFile:?]
        at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) [?:?]
        at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177) [?:?]
        at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) [?:?]
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) [?:?]
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) [?:?]
        at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) [?:?]
        at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) [?:?]
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) [?:?]
        at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) [?:?]
        at org.openhab.core.thing.internal.ThingManagerImpl.handleThingHandlerFactoryAddition(ThingManagerImpl.java:1056) [bundleFile:?]
        at org.openhab.core.thing.internal.ThingManagerImpl.onReadyMarkerAdded(ThingManagerImpl.java:1044) [bundleFile:?]
        at org.openhab.core.internal.service.ReadyServiceImpl.lambda$0(ReadyServiceImpl.java:52) [bundleFile:?]
        at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) [?:?]
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) [?:?]
        at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177) [?:?]
        at java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1746) [?:?]
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) [?:?]
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) [?:?]
        at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) [?:?]
        at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) [?:?]
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) [?:?]
        at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) [?:?]
        at org.openhab.core.internal.service.ReadyServiceImpl.notifyTrackers(ReadyServiceImpl.java:79) [bundleFile:?]
        at org.openhab.core.internal.service.ReadyServiceImpl.markReady(ReadyServiceImpl.java:52) [bundleFile:?]
        at org.openhab.core.config.xml.osgi.XmlDocumentBundleTracker.registerReadyMarker(XmlDocumentBundleTracker.java:419) [bundleFile:?]
        at org.openhab.core.config.xml.osgi.XmlDocumentBundleTracker.finishBundle(XmlDocumentBundleTracker.java:362) [bundleFile:?]
        at org.openhab.core.config.xml.osgi.XmlDocumentBundleTracker.processBundle(XmlDocumentBundleTracker.java:385) [bundleFile:?]
        at org.openhab.core.config.xml.osgi.XmlDocumentBundleTracker$2.run(XmlDocumentBundleTracker.java:347) [bundleFile:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
        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) [?:?]
Caused by: java.lang.ClassNotFoundException
        at javax.ws.rs.client.ClientFinder.newInstance(ClientFinder.java:120) ~[?:?]
        at javax.ws.rs.client.ClientFinder.find(ClientFinder.java:96) ~[?:?]
        at javax.ws.rs.client.ClientBuilder.newBuilder(ClientBuilder.java:44) ~[?:?]
        ... 45 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) ~[?:?]
        at javax.ws.rs.client.ClientFinder.find(ClientFinder.java:96) ~[?:?]
        at javax.ws.rs.client.ClientBuilder.newBuilder(ClientBuilder.java:44) ~[?:?]
        ... 45 more
@kaikreuzer kaikreuzer added bug An unexpected problem or unintended behavior of an add-on oh3 labels May 24, 2020
@kaikreuzer
Copy link
Member Author

@wborn Do you happen to know how to fix this? Would we have to directly add a dependency on org.apache.cxf.jaxrs.client.spec, which contains the client implementation? Would be very much against OSGi principles, though...

@kaikreuzer
Copy link
Member Author

Same problem exists for lametric time and probably all other bindings that use the JAX-RS Client.

@wborn
Copy link
Member

wborn commented May 24, 2020

I'm currently looking into #7648 which will also use the ClientBuilder so I'll run into it eventually.

@kaikreuzer
Copy link
Member Author

Only if you test it on openHAB 3, otherwise all will seem fine...

@wborn
Copy link
Member

wborn commented May 24, 2020

Did you also try if you can get it injected using a @Reference instead of using the static method?

@wborn
Copy link
Member

wborn commented May 24, 2020

It seems to work for me:

    @Activate
    public HandlerFactory(@Reference ClientBuilder clientBuilder) {
        Client client = clientBuilder.readTimeout(5, TimeUnit.SECONDS).connectTimeout(10, TimeUnit.SECONDS).build();
        Map<String, Object> properties = client.getConfiguration().getProperties();
        properties.entrySet().forEach(property -> System.out.println(property.getKey() + ": " + property.getValue()));
    }

Prints the properties:

http.receive.timeout: 5000
http.connection.timeout: 10000

Which correspond with those in the CXF ClientProperties.java.

So on the 2.5.x branch, if it throws an exception using the static method you should wait for the builder to be injected by the optional @Reference... then you can set the properties using those CXF names instead of the Jersey names. :-)

@kaikreuzer
Copy link
Member Author

You mean something like this? #7789
Disclaimer: I didn't test it yet on OH3.

@wborn
Copy link
Member

wborn commented May 25, 2020

Yes something like that was what I had in mind.

@kaikreuzer
Copy link
Member Author

Just pushed a few more changes/fixes to it...

@openhab-bot
Copy link
Collaborator

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/send-notifications-via-jython-script/124968/6

@openhab-bot
Copy link
Collaborator

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/send-notifications-via-jython-script/124968/8

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.

3 participants