<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    ClassCastException: org.jboss.cache.pojo.impl.PojoCacheImpl cannot be cast to org.jboss.cache.pojo.PojoCache
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/viral.ghariwala">Viral Ghariwala</a> in <i>JBoss Cache POJO Edition</i> - <a href="http://community.jboss.org/message/545340#545340">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Friends,</p><p>I'm 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.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><table border="1" cellpadding="3" cellspacing="0" style="width: 100%; border: 1px solid #000000;"><tbody><tr><td><p>MBeanServer server = MBeanServerLocator.locateJBoss();</p><p>ObjectName on = null;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>try {</p><p style="padding-left: 30px; "><span> </span>on = new ObjectName("jboss.cache:service=PojoCache");</p><p><span> </span>} catch (MalformedObjectNameException e) {</p><p style="padding-left: 30px; "><span> </span>logger.error("The format of the string does not correspond to a valid ObjectName.", e);</p><p><span> </span>} catch (NullPointerException e) {</p><p style="padding-left: 30px; "><span> </span>logger.error("An application attempts to use null in a case where an object is required.", e);</p><p><span> </span>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"><span> </span>&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>PojoCacheJmxWrapperMBean cacheWrapper = (PojoCacheJmxWrapperMBean) MBeanServerInvocationHandler.</p><p style="padding-left: 330px;">newProxyInstance(server, on, PojoCacheJmxWrapperMBean.class,false);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span> </span>PojoCache pojoCache = cacheWrapper.getPojoCache();</p></td></tr><tr><td></td></tr><tr><td></td></tr></tbody></table><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Below is the cache configuration file I'm using. This file is copied to 'deploy' directory of 'default' server.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><table border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse;"><tbody><tr><th align="center" style="background-color: #6a17e7;"><span style="color: #ffffff;">pojocache-jboss-beans.xml</span></th></tr><tr><td><div id="_mcePaste">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</div><div id="_mcePaste">&lt;deployment xmlns="urn:jboss:bean-deployer:2.0"&gt;</div><div id="_mcePaste"> </div><div id="_mcePaste" style="padding-left: 30px; ">&lt;!-- First we create a Configuration object for the cache --&gt;</div><div id="_mcePaste" style="padding-left: 30px; ">&lt;bean name="CacheConfiguration"&gt;</div><div id="_mcePaste" style="padding-left: 60px; ">&lt;!-- Externally injected services --&gt;</div><div id="_mcePaste" style="padding-left: 60px; ">&lt;property name="runtimeConfig"&gt;</div><div id="_mcePaste" style="padding-left: 90px; ">&lt;bean name="CacheRuntimeConfiguration"&gt;</div><div id="_mcePaste" style="padding-left: 120px; ">&lt;property name="transactionManager"&gt;</div><div id="_mcePaste" style="padding-left: 150px; ">&lt;inject bean="jboss:service=TransactionManager" property="TransactionManager" /&gt;</div><div id="_mcePaste" style="padding-left: 120px; ">&lt;/property&gt;</div><div id="_mcePaste" style="padding-left: 90px; ">&lt;/bean&gt;</div><div id="_mcePaste" style="padding-left: 60px; ">&lt;/property&gt;</div><div id="_mcePaste" style="padding-left: 60px; ">&lt;property name="multiplexerStack"&gt;udp&lt;/property&gt;</div><div id="_mcePaste" style="padding-left: 60px; ">&lt;property name="clusterName"&gt;PojoCacheCluster&lt;/property&gt;</div><div id="_mcePaste" style="padding-left: 60px; ">&lt;property name="isolationLevel"&gt;REPEATABLE_READ&lt;/property&gt;</div><div id="_mcePaste" style="padding-left: 60px; ">&lt;property name="cacheMode"&gt;REPL_SYNC&lt;/property&gt;</div><div id="_mcePaste" style="padding-left: 60px; ">&lt;property name="stateRetrievalTimeout"&gt;15000&lt;/property&gt;</div><div id="_mcePaste" style="padding-left: 60px; ">&lt;property name="syncReplTimeout"&gt;20000&lt;/property&gt;</div><div id="_mcePaste" style="padding-left: 60px; ">&lt;property name="lockAcquisitionTimeout"&gt;15000&lt;/property&gt;</div><div id="_mcePaste" style="padding-left: 60px; ">&lt;property name="exposeManagementStatistics"&gt;true&lt;/property&gt;</div><div id="_mcePaste" style="padding-left: 30px; ">&lt;/bean&gt;</div><div id="_mcePaste"> </div><div id="_mcePaste" style="padding-left: 30px; ">&lt;bean name="PojoCacheJmxWrapper"&gt;</div><div id="_mcePaste" style="padding-left: 60px; ">&lt;annotation&gt;@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.cache:service=PojoCache", exposedInterface=org.jboss.cache.pojo.jmx.PojoCacheJmxWrapperMBean.class, registerDirectly=true)&lt;/annotation&gt;</div><div id="_mcePaste" style="padding-left: 60px; ">&lt;property name="configuration"&gt;</div><div id="_mcePaste" style="padding-left: 90px; ">&lt;inject bean="CacheConfiguration" /&gt;</div><div id="_mcePaste" style="padding-left: 60px; ">&lt;/property&gt;</div><div id="_mcePaste" style="padding-left: 30px; ">&lt;/bean&gt;</div><div id="_mcePaste"> </div><div id="_mcePaste">&lt;/deployment&gt;</div></td></tr></tbody></table><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Please help to resolve this.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thank you.</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/545340#545340">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Cache POJO Edition at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2054">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>