什么使我无法在我的WAB中使用EJB注入?

时间:2012-02-26 09:09:55

标签: java osgi glassfish-3 war ejb-3.1

我尝试从我的WAB访问@singleton EJB,但它因“模块状态不一致”错误而失败。

我创建了一个Web Archive Bundle,到目前为止一切都运行良好。但我想访问我刚刚创建的EJB。

我在我的servlet监听器中使用注入:

@EJB(name="Config")
private Configuration config;

当我将WAB部署为简单WAR时,注入工作正常,但OSGI Activator未激活(这是正常的)。

如果我将WAB部署为WAB,则激活OSGI Activator,触发servlet侦听器,但注入不起作用,则部署失败并显示此堆栈跟踪:

    [#|2012-02-26T00:39:34.172+0100|WARNING|glassfish3.1.1|org.glassfish.osgijavaeebase|_ThreadID=26;_ThreadName=Thread-3;|Failed to deploy bundle WABPluginToto [366]
org.glassfish.osgijavaeebase.DeploymentException: Deployment of WABPluginToto [366] failed because of following reason: Failed while deploying bundle WABPluginToto [366] : java.lang.RuntimeException: Failed to deploy bundle [ WABPluginToto [366] ], root cause: Exception while loading the app
    at org.glassfish.osgijavaeebase.AbstractOSGiDeployer.deploy(AbstractOSGiDeployer.java:125)
    at org.glassfish.osgijavaeebase.OSGiContainer.deploy(OSGiContainer.java:154)
    at org.glassfish.osgijavaeebase.JavaEEExtender.deploy(JavaEEExtender.java:107)
    at org.glassfish.osgijavaeebase.JavaEEExtender.access$200(JavaEEExtender.java:61)
    at org.glassfish.osgijavaeebase.JavaEEExtender$HybridBundleTrackerCustomizer$1.call(JavaEEExtender.java:151)
    at org.glassfish.osgijavaeebase.JavaEEExtender$HybridBundleTrackerCustomizer$1.call(JavaEEExtender.java:148)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.RuntimeException: Failed to deploy bundle [ WABPluginToto [366] ], root cause: Exception while loading the app
    at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.deploy(OSGiDeploymentRequest.java:196)
    at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.execute(OSGiDeploymentRequest.java:118)
    at org.glassfish.osgijavaeebase.AbstractOSGiDeployer.deploy(AbstractOSGiDeployer.java:121)
    ... 10 more
Caused by: org.glassfish.deployment.common.DeploymentException: Error in linking security policy for WABPluginToto_1.0.0.SNAPSHOT -- Inconsistent Module State
    at com.sun.enterprise.security.SecurityUtil.linkPolicyFile(SecurityUtil.java:337)
    at com.sun.enterprise.security.SecurityDeployer.linkPolicies(SecurityDeployer.java:279)
    at com.sun.enterprise.security.SecurityDeployer.access$100(SecurityDeployer.java:81)
    at com.sun.enterprise.security.SecurityDeployer$AppDeployEventListener.event(SecurityDeployer.java:114)
    at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:128)
    at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:270)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.deploy(OSGiDeploymentRequest.java:183)
    ... 12 more

我真的不明白为什么。

我还有一个问题:如果我尝试在OSGI Activator中使用注入,则该属性始终为null。

如何在OSGI实例中使用我的EJB?

谢谢大家。

0 个答案:

没有答案