3 Replies Latest reply on Jul 12, 2012 2:33 AM by Viktor Mikho

    ClassCastException when accessing CacheManager in jBoss 7.1.1

    Viktor Mikho Newbie

      Hi,

       

      I am newby with Infinispan, don't hit me hard please.

      I am trying to access cache within jBoss 7.1.1.Final server. The intent is to use cache within EJB.

      We use java 1.6, hence code uses JNDI lookup:

       

       

      @PostConstruct

        private void initMe(){

       

            InitialContext ic = new InitialContext();

            Object fromLookup = ic.lookup("java:jboss/infinispan/jboss-as7-quickstart");

            log.log(Level.INFO, "******************************** fromLookup.getClass()= " + fromLookup.getClass() );

            DefaultEmbeddedCacheManager cm = (DefaultEmbeddedCacheManager)fromLookup;

      ....

       

      As a result I get class cast exception(note that class signatures are the same): 

       

      27.0.0.1-8443-3) ******************************** fromLookup.getClass()= class org.jboss.as.clustering.infinispan.DefaultEmbeddedCacheManager

      09:34:48,043 SEVERE [xxx.SystemConfig] (http--127.0.0.1-8443-3) Could not cust jboss-as7-quickstart: java.lang.ClassCastException:

      org.jboss.as.clustering.infinispan.DefaultEmbeddedCacheManager cannot be cast to

      org.jboss.as.clustering.infinispan.DefaultEmbeddedCacheManager

       

       

      Looks like build issue...difference in class serial id?

       

      My maven dependancy is

       

      <dependency>

      <groupId>org.jboss.as</groupId>

      <artifactId>jboss-as-clustering-infinispan</artifactId>

      <version>7.1.1.Final</version>

      </dependency>

       

       

      Extract from standalone.xml:

       

                  <cache-container name="jboss-as7-quickstart" default-cache="jboss-as7-quickstart-cache" jndi-name="java:jboss/infinispan/jboss-as7-quickstart">

                      <local-cache name="jboss-as7-quickstart-cache" start="EAGER"/>

                  </cache-container>

       

      Any hints?

       

      Cheers,

       

      Viktor