"NoClassDefFoundError" while running "bundleContext.registerService" [message #1752223] |
Fri, 20 January 2017 01:11  |
Eclipse User |
|
|
|
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!
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03907 seconds