既存の OSGi/Felix/iPOJO アプリを Windows から Android に移植しています。アプリは SLF4J を使用しています。slf4j-android をバンドルとしてデプロイしました。ただし、ロガーをインスタンス化しようとしている行でjava.lang.NoClassDefFoundError: android.util.Logを取得しています。
SLF4J のドキュメントによると、クラスパスに slf4j-android jar を配置するだけでよく、それ以上の構成は必要ありません。( http://www.slf4j.org/android/ )
私のロガーは次のように宣言されています:
private static final Logger logger = LoggerFactory.getLogger("DefaultActionManager");
スタック トレースが不平を言っている行は次のとおりです。
logger.info("Bound new action list for state " + state);
完全な方法は次のとおりです。
@Override
@Bind(aggregate = true)
public void bindActionList(final ActionList actionList) {
final State state = actionList.getState();
final ActionList replacedActionList = actionLists.put(state, actionList);
logger.info("Bound new action list for state " + state);
if (replacedActionList != null) {
logger.warn(state + " previously had an action list associated with it. This new action list replaced it.");
}
}
ロガーを参照すると、android.util.Log で NoClassDefFoundError が発生する理由はありますか?
完全なスタック トレース:
{ERROR] : The method bindActionList in the implementation class myCompany.DefaultActio
nManager throws an exception : android.util.Log
java.lang.NoClassDefFoundError: android.util.Log
at org.slf4j.impl.AndroidLogger.info(AndroidLogger.java:151)
at myCompany.DefaultActionManager.__bindActionList(DefaultActionManager.java:120)
at myCompany.DefaultActionManager.bindActionList(DefaultActionManager.java)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at org.apache.felix.ipojo.util.Callback.call(Callback.java:260)
at org.apache.felix.ipojo.handlers.dependency.DependencyCallback.callOnInstance(DependencyCa
llback.java:309)
at org.apache.felix.ipojo.handlers.dependency.Dependency.invokeCallback(Dependency.java:315)
at org.apache.felix.ipojo.handlers.dependency.Dependency.onObjectCreation(Dependency.java:28
0)
at org.apache.felix.ipojo.handlers.dependency.DependencyHandler.__M_onCreation(DependencyHan
dler.java:643)
at org.apache.felix.ipojo.handlers.dependency.DependencyHandler.onCreation(DependencyHandler
.java)
at org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:870)
at org.apache.felix.ipojo.util.Callback.call(Callback.java:233)
at org.apache.felix.ipojo.util.Callback.call(Callback.java:193)
at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallback.call(LifecycleCallba
ck.java:86)
at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChan
ged(LifecycleCallbackHandler.java:162)
at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(
LifecycleCallbackHandler.java)
at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:472)
at org.apache.felix.ipojo.InstanceManager.stateChanged(InstanceManager.java:1340)
at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:497)
at org.apache.felix.ipojo.HandlerManager.stateChanged(HandlerManager.java:239)
at org.apache.felix.ipojo.Handler.setValidity(Handler.java:174)
at org.apache.felix.ipojo.handlers.dependency.DependencyHandler.__M_checkContext(DependencyH
andler.java:186)
at org.apache.felix.ipojo.handlers.dependency.DependencyHandler.checkContext(DependencyHandl
er.java)
at org.apache.felix.ipojo.handlers.dependency.DependencyHandler.__M_validate(DependencyHandl
er.java:149)
at org.apache.felix.ipojo.handlers.dependency.DependencyHandler.validate(DependencyHandler.j
ava)
at org.apache.felix.ipojo.util.DependencyModel.validate(DependencyModel.java:642)
at org.apache.felix.ipojo.util.DependencyModel.computeDependencyState(DependencyModel.java:3
10)
at org.apache.felix.ipojo.util.DependencyModel.manageArrival(DependencyModel.java:399)
at org.apache.felix.ipojo.util.DependencyModel.addedService(DependencyModel.java:335)
at org.apache.felix.ipojo.util.Tracker$Tracked.trackAdding(Tracker.java:725)
at org.apache.felix.ipojo.util.Tracker$Tracked.track(Tracker.java:686)
at org.apache.felix.ipojo.util.Tracker$Tracked.serviceChanged(Tracker.java:647)
at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispat
cher.java:932)
at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java
:793)
at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:543
)
at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4260)
at org.apache.felix.framework.Felix.registerService(Felix.java:3275)
at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:346)
at org.apache.felix.ipojo.IPojoContext.registerService(IPojoContext.java:385)
at org.apache.felix.ipojo.handlers.providedservice.ProvidedService.registerService(ProvidedS
ervice.java:362)
at org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandler.__M_stateChanged(P
rovidedServiceHandler.java:509)
at org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandler.stateChanged(Provi
dedServiceHandler.java)
at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:472)
at org.apache.felix.ipojo.InstanceManager.stateChanged(InstanceManager.java:1340)
at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:497)
at org.apache.felix.ipojo.HandlerManager.stateChanged(HandlerManager.java:239)
at org.apache.felix.ipojo.Handler.setValidity(Handler.java:174)
at org.apache.felix.ipojo.handlers.dependency.DependencyHandler.__M_checkContext(DependencyH
andler.java:186)
at org.apache.felix.ipojo.handlers.dependency.DependencyHandler.checkContext(DependencyHandl
er.java)
at org.apache.felix.ipojo.handlers.dependency.DependencyHandler.__M_validate(DependencyHandl
er.java:149)
at org.apache.felix.ipojo.handlers.dependency.DependencyHandler.validate(DependencyHandler.j
ava)
at org.apache.felix.ipojo.util.DependencyModel.validate(DependencyModel.java:642)
at org.apache.felix.ipojo.util.DependencyModel.computeDependencyState(DependencyModel.java:3
10)
at org.apache.felix.ipojo.util.DependencyModel.manageArrival(DependencyModel.java:399)
at org.apache.felix.ipojo.util.DependencyModel.addedService(DependencyModel.java:335)
at org.apache.felix.ipojo.util.Tracker$Tracked.trackAdding(Tracker.java:725)
at org.apache.felix.ipojo.util.Tracker$Tracked.track(Tracker.java:686)
at org.apache.felix.ipojo.util.Tracker$Tracked.serviceChanged(Tracker.java:647)
at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispat
cher.java:932)
at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java
:793)
at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:543
)
at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4260)
at org.apache.felix.framework.Felix.registerService(Felix.java:3275)
at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:346)
at org.apache.felix.ipojo.IPojoContext.registerService(IPojoContext.java:385)
at org.apache.felix.ipojo.handlers.providedservice.ProvidedService.registerService(ProvidedS
ervice.java:362)
at org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandler.__M_stateChanged(P
rovidedServiceHandler.java:509)
at org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandler.stateChanged(Provi
dedServiceHandler.java)
at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:472)
at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:354)
at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:178)
at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:301)
at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:238)
at org.apache.felix.ipojo.InstanceCreator$ManagedInstance.create(InstanceCreator.java:343)
at org.apache.felix.ipojo.InstanceCreator.addInstance(InstanceCreator.java:89)
at org.apache.felix.ipojo.Extender.parse(Extender.java:306)
at org.apache.felix.ipojo.Extender.startManagementFor(Extender.java:237)
at org.apache.felix.ipojo.Extender.access$600(Extender.java:52)
at org.apache.felix.ipojo.Extender$CreatorThread.run(Extender.java:769)
at java.lang.Thread.run(Thread.java:856)