I recently have been working on adding a couple of different cache providers for Model-Glue 3 .

So I was getting my head round Andrew Powell's CF_EHCache so that I can write an interface for it that Model-Glue can use, which should be simple enough since it already uses a SimpleTimedCache, when I come across a very odd thing, with the code out of the box I got the following error:

The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code. Null Pointers are another name for undefined values.

So I started dumping my way through it, so to speak, but it would work... eh?!

	<cfscript>
		var mBeanServer     = createObject('java','java.lang.management.ManagementFactory').getPlatformMBeanServer();

			variables.manager	= createObject('java','net.sf.ehcache.CacheManager');
			variables.manager.create(javacast("string",expandPath('#arguments.scope#.xml')));
			variables.cacheName = arguments.cacheName;
	</cfscript>
	<cfdump var="#variables.manager#">
	<cfset createObject('java','net.sf.ehcache.management.ManagementService').registerMBeans(variables.manager,mBeanServer,
		javacast("boolean",false),
		javacast("boolean",false),
		javacast("boolean",false),
		javacast("boolean",true))>
<cfset variables.manager.addCache(javacast("string",arguments.cacheName))>

 

The above is the constructor code, I have split it out a bit so that you can see what is happening, but if call the above code without the cfdump, I get an error, but if remove it, it crashes. I have never seen something like this before.

UPDATE!

This morning, writing this post, I realised that in the third line I had forgotten to add the .init() to the CacheManager. Go figure! Seems that cfdump does the init for you eh?