Friends,
I am using Pojo Cache first time. I'm getting ClassCastException: org.jboss.cache.pojo.impl.PojoCacheImpl cannot be cast to org.jboss.cache.pojo.PojoCache while I try to retrieve an instance of PojoCache using following code.
MBeanServer server = MBeanServerLocator.locateJBoss(); ObjectName on = null; try { on = new ObjectName("jboss.cache:service=PojoCache"); } catch (MalformedObjectNameException e) { logger.error("The format of the string does not correspond to a valid ObjectName.", e); } catch (NullPointerException e) { logger.error("An application attempts to use null in a case where an object is required.", e); }
PojoCacheJmxWrapperMBean cacheWrapper = (PojoCacheJmxWrapperMBean) MBeanServerInvocationHandler. newProxyInstance(server, on, PojoCacheJmxWrapperMBean.class,false); PojoCache pojoCache = cacheWrapper.getPojoCache(); |
Below is the cache configuration file I'm using. This file is copied to 'deploy' directory of 'default' server.
pojocache-jboss-beans.xml |
---|
<?xml version="1.0" encoding="UTF-8"?> <deployment xmlns="urn:jboss:bean-deployer:2.0"> <!-- First we create a Configuration object for the cache --> <bean name="CacheConfiguration"> <!-- Externally injected services --> <property name="runtimeConfig"> <bean name="CacheRuntimeConfiguration"> <property name="transactionManager"> <inject bean="jboss:service=TransactionManager" property="TransactionManager" /> </property> </bean> </property> <property name="multiplexerStack">udp</property> <property name="clusterName">PojoCacheCluster</property> <property name="isolationLevel">REPEATABLE_READ</property> <property name="cacheMode">REPL_SYNC</property> <property name="stateRetrievalTimeout">15000</property> <property name="syncReplTimeout">20000</property> <property name="lockAcquisitionTimeout">15000</property> <property name="exposeManagementStatistics">true</property> </bean> <bean name="PojoCacheJmxWrapper"> <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.cache:service=PojoCache", exposedInterface=org.jboss.cache.pojo.jmx.PojoCacheJmxWrapperMBean.class, registerDirectly=true)</annotation> <property name="configuration"> <inject bean="CacheConfiguration" /> </property> </bean> </deployment> |
Please help to resolve this.
Thank you.
I copied the cache configuration file to the 'deploy' directory of 'all' server and it worked.