Spring DM(动态模块)、OSGI和Greenpages应用程序

Spring DM(动态模块)、OSGI和Greenpages应用程序,spring,osgi,eclipse-virgo,spring-dm,Spring,Osgi,Eclipse Virgo,Spring Dm,“Greenpages应用程序”是EclipseVirgo站点中提供的一个示例web应用程序,它提供了一起使用OSGI和SpringDM的示例,可以部署在Virgo容器中。请参阅:。我能够运行应用程序,没有错误。但是,当我尝试实现org.springframework.osgi.context.event.OsgiBundleApplicationContextListener接口时,一切都出错了,我开始出现以下错误: java.lang.IllegalArgumentException:必需的

“Greenpages应用程序”是EclipseVirgo站点中提供的一个示例web应用程序,它提供了一起使用OSGI和SpringDM的示例,可以部署在Virgo容器中。请参阅:。我能够运行应用程序,没有错误。但是,当我尝试实现org.springframework.osgi.context.event.OsgiBundleApplicationContextListener接口时,一切都出错了,我开始出现以下错误:

java.lang.IllegalArgumentException:必需的属性“bundleContext” 尚未设置

OsgiBundleApplicationContextListener接口提供了一种侦听BundleContext事件的方法。见:

我的代码:

公共类ApplicationContextObserver实现OsgiBundleApplicationContextListener{ 私有瞬态int countRefreshed=0; 私有瞬态int countClosed=0

public void onOsgiApplicationEvent(OsgiBundleApplicationContextEvent evt) {
    if(evt instanceof
            OsgiBundleContextRefreshedEvent) {
        countRefreshed++;
    } else if(evt instanceof
            OsgiBundleContextClosedEvent) {
        countClosed++;
    }
}
public int getCountRefreshed() {
    return countRefreshed;
}
public int getCountClosed() {
    return countClosed;
}
}

以及声明的bean:

<bean id="ApplicationContextObserver" class="greenpages.ApplicationContextObserver" />
<osgi:service ref="ApplicationContextObserver" interface="org.springframework.osgi.context.event.OsgiBundleApplicationContextListener" />      

最糟糕的是,有时这个错误根本不会出现,但是当我在容器中部署另一个包时,侦听器不会被调用


出了什么问题(如果可能的话,你能用Virgo容器、SpringDM和这个监听器附加一个正在运行的示例吗)?

请查看。更多细节可以在(特别是第节)中找到。

Spring DM已经死了很长一段时间,您应该使用Eclipse Virgo类,而不是旧的Spring DM类。好的。我可以从类路径中删除SpringDM,但我需要保留SpringCore本身,因为我的项目是基于Spring的。我需要如何使用EclipseVirgo中的类(以及我需要如何以正确的方式这样做)来使用BundleContext listener使一切工作正常?你能提供任何maven项目的例子吗?谢谢