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



      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:




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

      ******************************** fromLookup.getClass()= class org.jboss.as.clustering.infinispan.DefaultEmbeddedCacheManager

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

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




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


      My maven dependancy is









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



      Any hints?