Community

exception from CacheJmxWrapperMBean.getCache()

created by Peter Petrovics in JBoss Cache - View the full discussion

I'm trying to reach the same cache from two different webapps running on the same Tomcat.

 

The first time it starts I'm registering with the following code:

{code}

jbossCache = new DefaultCacheFactory().createCache(configFile);
cacheJmxWrapper = new CacheJmxWrapper(jbossCache);


ObjectInstance oi = mBeanServer.registerMBean(cacheJmxWrapper, on);

// tryied this way too:

//JmxRegistrationManager jmxRegManager = new  JmxRegistrationManager(mBeanServer, jbossCache, on);
//jmxRegManager.registerAllMBeans();

               
log.info("Cache started. MBean objName: " + oi.getObjectName());

{code}

 

I try to get a reference through JMX with this code:

{code}

mBeanServer = ManagementFactory.getPlatformMBeanServer();

 

cacheJmxWrapper =
                        (CacheJmxWrapperMBean) MBeanServerInvocationHandler.newProxyInstance(mBeanServer, on,
                        CacheJmxWrapperMBean.class, false);

 

Object o;   // just to show the issue
o = cacheJmxWrapper.getCache();

{code}

 

I receive the following exception from the last line:

{code}

java.lang.ClassCastException: org.jboss.cache.invocation.CacheInvocationDelegate cannot be cast to org.jboss.cache.Cache
        at $Proxy17.getCache(Unknown Source)

{code}

I tried several different methods to register/get reference.

Am I missing a point or is it a bug?

 

As I read JNDI would be a workaroun but can't find proper description how to setup (and setting on production server would be a bit complicated because of restricted access). I there any other way to reach the same cache from different webapps?

Reply to this message by going to Community

Start a new discussion in JBoss Cache at Community