• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Distributed cacheing using EHCache error...

Participant ,
May 28, 2009 May 28, 2009

Copy link to clipboard

Copied

I've been trying to leverage distributed caching in our application using EHCache http://ehcache.sourceforge.net/and Cristian Costantini's ehcache.cfc tag implementation here: http://cfehcache.riaforge.org/. It works well when I'm not trying to use it in distributed mode, but when I try to change the cache.xml file to include the distribution nodes.

I'm get the following exception:

java.lang.ClassCastException: net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory cannot be cast to net.sf.ehcache.distribution.CacheManagerPeerListenerFactory

Does anyone have any insight on how to debug this error or what it might be? Has anyone out there gotten EHcache working for distributed caching?

full dump:

"Error","jrpp-3","05/28/09","13:11:43","dev.test.com","Object Instantiation Exception.An exception occurred when instantiating a Java object. The class must not be an interface or an abstract class. Error: ''. The specific sequence of files included or processed is: I:\WWWRoot\test\_testing\Scribble\scratchPad.cfm, line: 28 "
coldfusion.runtime.java.JavaObjectInstantiationException: Object Instantiation Exception.
at coldfusion.runtime.java.JavaProxy.CreateObject(JavaProxy.java:161)
at coldfusion.runtime.java.JavaProxy.invoke(JavaProxy.java:63)
at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2272)
at cfCacheManager2ecfc1033799285$funcINIT.runFunction(I:\WWWRoot\test\com\cfehcache\CacheManager.cfc:28)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:418)
at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47)
at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:360)
at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:324)
at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:59)
at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:277)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:192)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:448)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:308)
at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2272)
at cfscratchPad2ecfm1382164412.runPage(I:\WWWRoot\test\_testing\Scribble\scratchPad.cfm:33)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:196)
at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:370)
at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:279)
at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48)
at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)
at coldfusion.filter.PathFilter.invoke(PathFilter.java:86)
at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70)
at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46)
at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
at coldfusion.CfmServlet.service(CfmServlet.java:175)
at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
at jrun.servlet.FilterChain.doFilter(FilterChain.java:86)
at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
at jrun.servlet.FilterChain.service(FilterChain.java:101)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286)
at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)
at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203)
at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at coldfusion.runtime.java.JavaProxy.CreateObject(JavaProxy.java:156)
... 41 more
Caused by: java.lang.ClassCastException: net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory cannot be cast to net.sf.ehcache.distribution.CacheManagerPeerListenerFactory
at net.sf.ehcache.config.ConfigurationHelper.createCachePeerListeners(ConfigurationHelper.java:309)
at net.sf.ehcache.CacheManager.configure(CacheManager.java:310)
at net.sf.ehcache.CacheManager.init(CacheManager.java:237)
at net.sf.ehcache.CacheManager.<init>(CacheManager.java:210)
... 46 more

TOPICS
Advanced techniques

Views

2.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 28, 2009 May 28, 2009

Copy link to clipboard

Copied

LATEST

I've resolved my issues and can now use very scalable distributed caching within my application across clustered servers and multiple instances.

This issue was caused by the JavaLoader.cfc he was using and how it loads the classes on line 90. I had to change the create method to have ColdFusion do the object creation. I removed:

<cfscript>

var class = getURLClassLoader().loadClass(arguments.className);

return createJavaProxy(class);

</cfscript>

and replaced it with:

<cfreturn createObject('java',arguments.className) />

Once I did this I no longer got the cast error. I'm not sure if this is an issue with the JavaLoader.cfc or the EHcache.cfc, but either way, it now works. Feel free to elaborate if you want...

If you're trying to get it working, you'll need to get over a few humps first. This is how I got it working with RMI distribution:

·         Downloaded the EHcache cfc tag from riaforge.com which is currently in verion 1.0 Alpha http://cfehcache.riaforge.org/

·         Enable "Reliable Multicast Protocol" on the servers NIC. (I'm using Windows 2003 server).

·         Add the ehcache.jar (currently version 1.6 beta 5) directory to your server’s classpath. I did this directly in the jvm.config file. (I had to add the classpath since the ehcache.jar was not under my JRun root, but in my web root. When I didn't add it directly to the classPath, I ran into a security policy issue that was throwing an error, something like: no security manager: RMI class loader disabled.)

·         create a cache.xml file like the one below

·         follow Cristian Costantini’s examples for adding and getting at the cache.

That's it, distributed cache. I like it!

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

      xsi:noNamespaceSchemaLocation="http://ehcache.sourceforge.net/ehcache.xsd">

      <diskStore path="java.io.tmpdir"/>

     

      <cacheManagerPeerProviderFactory

      class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"

      properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1,

      multicastGroupPort=4446, timeToLive=32"/>

                 

      <cacheManagerPeerListenerFactory

            class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory" />

           

      <defaultCache maxElementsInMemory="1000" eternal="false"

            timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true"

            diskSpoolBufferSizeMB="30" maxElementsOnDisk="10000000"

            diskPersistent="false" diskExpiryThreadIntervalSeconds="120"

            memoryStoreEvictionPolicy="LRU">

            <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"/>

      </defaultCache>

     

      <cache name="sampleDistributedCache1" maxElementsInMemory="10"

            eternal="true" overflowToDisk="false" memoryStoreEvictionPolicy="LRU">

            <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"/>

      </cache>

</ehcache>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation