在我将一个正在运行的EAR应用程序迁移到JBoss AS 7.1.1-Finel的过程中,我遇到了另一个我无法解决的问题。不久,EJB3会查找缓存容器并将数据存储在其中。
org.infinispan.manager.CacheContainer container = null;
...
public static CacheContainer getCacheContainer() {
if(container == null) {
try {
Context ctx = new InitialContext();
container = (CacheContainer) ctx
.lookup("java:jboss/infinispan/container/mycache");
} catch (NamingException e) {
e.getCause();
}
}
return container;
}
EAR以这种方式定义jboss-deployment-structure.xml中对infinispan的依赖:
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.hibernate" slot="main" />
<module name="org.infinispan" slot="main" />
<module name="org.jboss.as.clustering.infinispan" />
</dependencies>
</deployment>
</jboss-deployment-structure>
当我部署此代码时,出现以下错误:
Caused by: java.lang.NoClassDefFoundError: org/infinispan/manager/CacheContainer
有人能帮助我吗?
祝你好运, SK
答案 0 :(得分:2)
这仅适用于顶级部署,如here所述。您可能需要将org.infinispan
依赖项移至相关的sub-deployment
部分:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
...
<!-- This corresponds to the top level deployment. For a war this is the war's module, for an ear -->
<!-- This is the top level ear module, which contains all the classes in the EAR's lib folder -->
<deployment>
<dependencies>
...
</dependencies>
</deployment>
<sub-deployment name="myapp.war">
<!-- This corresponds to the module for a web deployment -->
<!-- it can use all the same tags as the <deployment> entry above -->
<dependencies>
<module name="org.infinispan" slot="main" />
</dependencies>
</sub-deployment>
...
</jboss-deployment-structure>