更新捆绑包时出现ArrayStoreException

时间:2012-07-24 18:23:22

标签: osgi classloader apache-felix

使用Apache Felix我在更新捆绑包时遇到ArrayStoreException。它发生在与更新的捆绑包不同的捆绑包中。受影响的捆绑包具有服务侦听器,该侦听器对更新的捆绑包注册的新服务作出反应。侦听器执行一些以ArrayStoreException结尾的代码。这是堆栈跟踪:

ERROR: Bundle com.elsten.bliss.platform [47] EventDispatcher: Error during dispatch. (java.lang.ArrayStoreException: com.elsten.bliss.music.policy.tag.tagtype.TagTypePolicy)
java.lang.ArrayStoreException: com.elsten.bliss.music.policy.tag.tagtype.TagTypePolicy
        at com.elsten.bliss.main.Main.getPolicies(Main.java:473)
        at com.elsten.bliss.main.Main.<init>(Main.java:150)
        at com.elsten.bliss.main.Main.startup(Main.java:143)
        at com.elsten.bliss.main.Activator$VersionServiceTracker.addingService(Activator.java:58)
        at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:980)
        at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:906)
        at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:262)
        at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:234)
        at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:941)
        at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.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.framework.BundleContextImpl.registerService(BundleContextImpl.java:352)
        at com.elsten.osgi.Activator.start(Activator.java:28)
        at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:641)
        at org.apache.felix.framework.Felix.activateBundle(Felix.java:1977)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:1895)
        at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)
        at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:931)
        at org.apache.felix.bundlerepository.impl.ResolverImpl.deploy(ResolverImpl.java:647)
        at com.elsten.bliss.updater.OnlineUpdater$2.run(OnlineUpdater.java:100)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:679)

getPolicies中的代码(是一种静态方法)可访问静态最终变量:

private static final MusicPolicy tagTypePolicy = new TagTypePolicy();
private static MusicPolicy[] policies;
private static MusicPolicy[] getPolicies(Version version) {

    if(policies==null) {
        final HttpClientConfiguration httpClientConfig = HttpClientConfigurations.userAgentAndAcceptGzip(version);
        policies = new MusicPolicy[] {
            tagTypePolicy
        };
    }
    return policies;
}

我的猜测是这与类加载有关;更新后,MusicPolicy或TagTypePolicy类不匹配。我有点困惑为什么会这样;鉴于这些是私有静态变量我虽然我的代码可以做它喜欢的。只有当静态导出到其他捆绑包时,我才认为可能会发生麻烦。

0 个答案:

没有答案