User Tools

Site Tools


classcastexception_with_apache_karaf_and_amdatu_web

ClassCastException with Apache Karaf and Amdatu Web

2015-06-17 16:43:43,431 | WARN  | karaf-sdm/deploy | fileinstall                      | 7 - org.apache.felix.fileinstall - 3.4.2 | Error while starting bundle: file:/opt/karaf-sdm/deploy/org.amdatu.web.rest.wink-2.0.2.jar
org.osgi.framework.BundleException: Activator start error in bundle org.amdatu.web.rest.wink [161].
	at org.apache.felix.framework.Felix.activateBundle(Felix.java:2196)[org.apache.felix.framework-4.2.1.jar:]
	at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)[org.apache.felix.framework-4.2.1.jar:]
	at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)[org.apache.felix.framework-4.2.1.jar:]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1245)[7:org.apache.felix.fileinstall:3.4.2]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1217)[7:org.apache.felix.fileinstall:3.4.2]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1207)[7:org.apache.felix.fileinstall:3.4.2]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:504)[7:org.apache.felix.fileinstall:3.4.2]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:358)[7:org.apache.felix.fileinstall:3.4.2]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:310)[7:org.apache.felix.fileinstall:3.4.2]
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
	at org.apache.felix.dm.ServiceUtil.getRankingAsInteger(ServiceUtil.java:54)[150:org.apache.felix.dependencymanager:3.1.0]
	at org.apache.felix.dm.ServiceUtil.getRanking(ServiceUtil.java:42)[150:org.apache.felix.dependencymanager:3.1.0]
	at org.apache.felix.dm.tracker.ServiceTracker$Tracked.setInitial(ServiceTracker.java:1059)[150:org.apache.felix.dependencymanager:3.1.0]
	at org.apache.felix.dm.tracker.ServiceTracker.open(ServiceTracker.java:371)[150:org.apache.felix.dependencymanager:3.1.0]
	at org.apache.felix.dm.tracker.ServiceTracker.open(ServiceTracker.java:311)[150:org.apache.felix.dependencymanager:3.1.0]
	at org.apache.felix.dm.tracker.ServiceTracker.open(ServiceTracker.java:287)[150:org.apache.felix.dependencymanager:3.1.0]
	at org.apache.felix.dm.impl.dependencies.ServiceDependencyImpl.start(ServiceDependencyImpl.java:419)[150:org.apache.felix.dependencymanager:3.1.0]
	at org.apache.felix.dm.impl.ComponentImpl.startTrackingOptional(ComponentImpl.java:708)[150:org.apache.felix.dependencymanager:3.1.0]
	at org.apache.felix.dm.impl.ComponentImpl.bindService(ComponentImpl.java:626)[150:org.apache.felix.dependencymanager:3.1.0]
	at org.apache.felix.dm.impl.ComponentImpl.access$400(ComponentImpl.java:52)[150:org.apache.felix.dependencymanager:3.1.0]
	at org.apache.felix.dm.impl.ComponentImpl$7.run(ComponentImpl.java:181)[150:org.apache.felix.dependencymanager:3.1.0]
	at org.apache.felix.dm.impl.SerialExecutor$1.run(SerialExecutor.java:47)[150:org.apache.felix.dependencymanager:3.1.0]
	at org.apache.felix.dm.impl.SerialExecutor.scheduleNext(SerialExecutor.java:84)[150:org.apache.felix.dependencymanager:3.1.0]
	at org.apache.felix.dm.impl.SerialExecutor.access$000(SerialExecutor.java:33)[150:org.apache.felix.dependencymanager:3.1.0]
	at org.apache.felix.dm.impl.SerialExecutor$1.run(SerialExecutor.java:50)[150:org.apache.felix.dependencymanager:3.1.0]
	at org.apache.felix.dm.impl.SerialExecutor.scheduleNext(SerialExecutor.java:84)[150:org.apache.felix.dependencymanager:3.1.0]
	at org.apache.felix.dm.impl.SerialExecutor.execute(SerialExecutor.java:68)[150:org.apache.felix.dependencymanager:3.1.0]
	at org.apache.felix.dm.impl.ComponentImpl.calculateStateChanges(ComponentImpl.java:231)[150:org.apache.felix.dependencymanager:3.1.0]
	at org.apache.felix.dm.impl.ComponentImpl.start(ComponentImpl.java:399)[150:org.apache.felix.dependencymanager:3.1.0]
	at org.apache.felix.dm.DependencyManager.add(DependencyManager.java:169)[150:org.apache.felix.dependencymanager:3.1.0]
	at org.amdatu.web.rest.wink.Activator.init(Activator.java:52)[161:org.amdatu.web.rest.wink:2.0.2]
	at org.apache.felix.dm.DependencyActivatorBase.start(DependencyActivatorBase.java:76)[150:org.apache.felix.dependencymanager:3.1.0]
	at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)[org.apache.felix.framework-4.2.1.jar:]
	at org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)[org.apache.felix.framework-4.2.1.jar:]

The problem is that the OSGi service property service.ranking must be an Integer (not only a number but of type Integer).

The bundle karaf.scr.command has a service.ranking value defined without a specific type (which defaults to a type of String). This caused an error when using the felix depenedency manager which expects an Integer.

One solution is to stop the bundle (if you don't need it).

Tested with Apache Karaf 3.0.3.

classcastexception_with_apache_karaf_and_amdatu_web.txt · Last modified: 2018/06/14 07:25 by mihael