Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse SmartHome » "NoClassDefFoundError" while running "bundleContext.registerService"(Light control demo just like hue example)
"NoClassDefFoundError" while running "bundleContext.registerService" [message #1752223] Fri, 20 January 2017 06:11 Go to next message
ren Junhua is currently offline ren JunhuaFriend
Messages: 3
Registered: January 2017
Junior Member
These days I am working on a light(flex) control demo by taking Hue Light example as referefence.
But I always got error while running "bundleContext.registerService(DiscoveryService.class.getName(), discoveryService, null); " in my code.
The error message is here:

[symbolicName=org.eclipse.smarthome.core.thing, className=org.eclipse.smarthome.core.thing.internal.ThingManager] - Exception occured while calling thing handler factory 'com.sengled.internal.FlexHandlerFactory@6e1413': java.lang.NoClassDefFoundError: org/osgi/framework/BundleContext
log


Part code is the following´╝Ü
public class FlexHandlerFactory extends BaseThingHandlerFactory {
......
@Override
protected ThingHandler createHandler(Thing thing) {
if (FlexBridgeHandler.SUPPORTED_THING_TYPES.contains(thing.getThingTypeUID())) {
FlexBridgeHandler handler = new FlexBridgeHandler((Bridge) thing);
registerLightDiscoveryService(handler);
return handler;
} else if (FlexHandler.SUPPORTED_THING_TYPES.contains(thing.getThingTypeUID())) {
return new FlexHandler(thing);
} else {
return null;
}
}
......
private synchronized void registerLightDiscoveryService(FlexBridgeHandler bridgeHandler) {
FlexDiscoveryService discoveryService = new FlexDiscoveryService(bridgeHandler);

discoveryService.activate();
ServiceRegistration aa=null;
if(bundleContext!=null){
try{ aa=bundleContext.registerService(DiscoveryService.class.getName(), discoveryService, null);
discoveryServiceRegs.put(bridgeHandler.getThing().getUID(),aa);
}
catch(Exception e){
}

}

}
.......


I am sure
in function "FlexDiscoveryService discoveryService = new FlexDiscoveryService(bridgeHandler);",bridgeHandler is not nul and discoveryService is not null.
And FlexDiscoveryService is defined as the following:
public class FlexDiscoveryService extends AbstractDiscoveryService implements FlexStatusListener{
......
}


I wonder what causes this error? The code in the Hue example also contains these code,how can it work before?
Thanks!
Re: "NoClassDefFoundError" while running "bundleContext.registerService" [message #1752228 is a reply to message #1752223] Fri, 20 January 2017 07:20 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 661
Registered: December 2011
Senior Member
That's difficult to say without a more detailed log excerpt and without seeing the code.
A NCDFE usually hints that you have some exception in a constructor of one of your classes. I'd suggest to use the debugger to step through your code and see, where exactly it fails.
Re: "NoClassDefFoundError" while running "bundleContext.registerService" [message #1752231 is a reply to message #1752228] Fri, 20 January 2017 07:58 Go to previous messageGo to next message
ren Junhua is currently offline ren JunhuaFriend
Messages: 3
Registered: January 2017
Junior Member
Hi,Thanks for your response.
Here is the error detail:

2017-01-20T08:40:13.944+0100 157 ERROR [symbolicName=org.eclipse.smarthome.core.thing, className=org.eclipse.smarthome.core.thing.internal.ThingManager] - Exception occured while calling thing handler factory 'com.sengled.internal.FlexHandlerFactory@10e576e': java.lang.NoClassDefFoundError: org/osgi/framework/BundleContext
java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org/osgi/framework/BundleContext
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:206)
at org.eclipse.smarthome.core.common.SafeMethodCaller.callAsynchronous(SafeMethodCaller.java:186)
at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:79)
at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:63)
at org.eclipse.smarthome.core.thing.internal.ThingManager.registerHandler(ThingManager.java:633)
at org.eclipse.smarthome.core.thing.internal.ThingManager.addThingHandlerFactory(ThingManager.java:1021)
at sun.reflect.GeneratedMethodAccessor38.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.prosyst.mbs.impl.services.scm.model.MethodInvoker.invoke(MethodInvoker.java:44)
at com.prosyst.mbs.impl.services.scm.model.ComponentReference.bind(ComponentReference.java:387)
at com.prosyst.mbs.impl.services.scm.model.ServiceComponentProp.bindReference(ServiceComponentProp.java:482)
at com.prosyst.mbs.impl.services.scm.InstanceProcess.dynamicBind(InstanceProcess.java:427)
at com.prosyst.mbs.impl.services.scm.Resolver.getEligible(Resolver.java:343)
at com.prosyst.mbs.impl.services.scm.SCRManager.serviceChanged(SCRManager.java:267)
at com.prosyst.mbs.impl.framework.module.security.BasicPEA.dispatch(BasicSecurityImpl.java:554)
at com.prosyst.mbs.framework.security.AbstractPEA.run(AbstractPEA.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at com.prosyst.mbs.framework.security.AbstractPEA.doPrivileged(AbstractPEA.java:42)
at com.prosyst.mbs.impl.framework.module.security.BasicSecurityImpl.doPrivileged(BasicSecurityImpl.java:306)
at com.prosyst.mbs.impl.framework.EventsManager.serviceChanged(EventsManager.java:1111)
at com.prosyst.mbs.impl.framework.BundleContextImpl.registerService(BundleContextImpl.java:686)
at com.prosyst.mbs.impl.framework.BundleContextImpl.registerService(BundleContextImpl.java:645)
at com.prosyst.mbs.impl.services.scm.InstanceProcess.registerService(InstanceProcess.java:542)
at com.prosyst.mbs.impl.services.scm.InstanceProcess.buildComponents(InstanceProcess.java:204)
at com.prosyst.mbs.impl.services.scm.Resolver.buildNewlySatisfied(Resolver.java:478)
at com.prosyst.mbs.impl.services.scm.Resolver.enableComponents(Resolver.java:226)
at com.prosyst.mbs.impl.services.scm.SCRManager.performWork(SCRManager.java:876)
at com.prosyst.mbs.impl.services.scm.SCRManager$QueuedJob.dispatch(SCRManager.java:846)
at com.prosyst.mbs.impl.services.scm.WorkThread.run(WorkThread.java:82)
at com.prosyst.util.impl.tpt.threadpool.PEA.run(PEA.java:11)
at java.security.AccessController.doPrivileged(Native Method)
at com.prosyst.util.impl.tpt.threadpool.ExecutorImpl.run(ExecutorImpl.java:186)
Caused by: java.lang.NoClassDefFoundError: org/osgi/framework/BundleContext
at com.sengled.internal.FlexHandlerFactory.registerLightDiscoveryService(FlexHandlerFactory.java:130)
at com.sengled.internal.FlexHandlerFactory.createHandler(FlexHandlerFactory.java:110)
at org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory.registerHandler(BaseThingHandlerFactory.java:133)
at org.eclipse.smarthome.core.thing.internal.ThingManager$7.call(ThingManager.java:637)
at org.eclipse.smarthome.core.thing.internal.ThingManager$7.call(ThingManager.java:1)
at org.eclipse.smarthome.core.common.SafeMethodCaller$CallableWrapper.call(SafeMethodCaller.java:177)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.osgi.framework.BundleContext, from bundle com.sengled
at com.prosyst.mbs.impl.framework.DefaultClassProvider.loadClass_(DefaultClassProvider.java:655)
at com.prosyst.mbs.impl.framework.DefaultClassProvider.loadClass(DefaultClassProvider.java:488)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 10 more


By the way ,I usually run my code in qivicon device and see the log there .Error disappears when I comment " aa=bundleContext.registerService(DiscoveryService.class.getName(), discoveryService, null);".....

Thank you!

[Updated on: Fri, 20 January 2017 08:05]

Report message to a moderator

Re: "NoClassDefFoundError" while running "bundleContext.registerService" [message #1752234 is a reply to message #1752231] Fri, 20 January 2017 08:08 Go to previous messageGo to next message
Simon Kaufmann is currently offline Simon KaufmannFriend
Messages: 51
Registered: January 2011
Member
Just a wild guess: Do you have in your binding's MANIFEST.MF an import of the org.osgi.framework package declared?
Re: "NoClassDefFoundError" while running "bundleContext.registerService" [message #1752235 is a reply to message #1752234] Fri, 20 January 2017 08:10 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 661
Registered: December 2011
Senior Member
What call do you do in line FlexHandlerFactory.java:130?
Re: "NoClassDefFoundError" while running "bundleContext.registerService" [message #1752256 is a reply to message #1752235] Fri, 20 January 2017 10:48 Go to previous messageGo to next message
ren Junhua is currently offline ren JunhuaFriend
Messages: 3
Registered: January 2017
Junior Member
in line FlexHandlerFactory.java:130, is the registerService function:
bundleContext.registerService(DiscoveryService.class.getName(), discoveryService, null);

In fact ,I don't import the org.osgi.framework package in MANIFEST.MF of my binding. Because the version is 3.10,and something doesn't work well in this version.
So I download osgi-3.9.1 version and import it in my build path.
Maybe it is caused by this ? But how Can I change the version in the package list when selecting package and then put it to MANIFEST.MF.
Re: "NoClassDefFoundError" while running "bundleContext.registerService" [message #1797068 is a reply to message #1752256] Wed, 24 October 2018 17:38 Go to previous message
Dalia El-Dib is currently offline Dalia El-DibFriend
Messages: 1
Registered: October 2018
Junior Member
How did you resolve your issue, I am facing a similar one?
Previous Topic:How to Use the Recently Added MQTT Binding
Next Topic:ESH + Authorisation + OPTIONS method
Goto Forum:
  


Current Time: Wed Nov 14 09:14:21 GMT 2018

Powered by FUDForum. Page generated in 0.03025 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top