Domanda

In my process to migrate a working EAR application to JBoss AS 7.1.1-Finel I faced another problem what I can not solve. Shortly, an EJB3 looks up for a cache container and stores data in it.

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;
}

The EAR defines the dependency on infinispan in the jboss-deployment-structure.xml, in this way:

<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>

When I deploy this code I get the following error:

Caused by: java.lang.NoClassDefFoundError: org/infinispan/manager/CacheContainer

Could somebody help me?

Best regards, SK

È stato utile?

Soluzione

This will only work for a top-level deployment, as described here. You may need to move the org.infinispan dependency to the relevant sub-deployment section:

<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>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top