Fixing "java method security exception" when installing Mango Blog

I've just setup a new blog which I'm going to use for tracking my weight loss and fitness goals this year. As part of the planning for the project I had to decide what blog software to use. I was all set to go with BlogCFC (as I use for this blog) but then Mango Blog came onto my radar. The brilliant API system and easy to use skinning facilities swung me so I decided to build the new blog using Mango.

However, when I uploaded the code to my CF7 hosting and accessed the web root I got this error:

java method security exception. A security exception occurred while
invoking java method on a "java.lang.Class" object. MethodName is
getMethods. Possible cause: createobject function and cfobject tag are
disabled in the security sand box.

After searching the MangoBlog forums I found other people had experienced this problem. However, the author of MangoBlog could only suggest that maybe the ISP has disabled the CreateObject function.

To check this, I did some tests but found that CreateObject was working perfectly.

Very weird. However, I have found the solution - though one which makes 0 sense to me.

If you get this, to fix open up application.cfc.

Now, comment out the entire onError function:

<cffunction name="onError" returnType="void">
<cfargument name="Exception" required="true" />
<cfargument name="EventName" type="String" required="true" />
<cfset request.message = createObject("component",variables.componentsPath & "Message") />
<cfset request.message.setTitle("Error: " & arguments.EventName) />
<cfset request.message.setText(arguments.exception.message) />
<cfset request.message.setStatus("error") />
<cfset request.message.setData(arguments.exception.detail) />

<!--- Set appropriate HTTP status code --->
<cfif REFindNoCase("NotFound$",arguments.exception.type)>
<cfheader statuscode="404" statustext="Not Found" />
<cfelse>
<cfheader statuscode="500" statustext="Internal Server Error" />
</cfif>

<cftry>
<cfsetting enablecfoutputonly="false">
<cfinclude template="generic.cfm">
<cfcatch type="any">
<cfsetting enablecfoutputonly="false">
<cfinclude template="error.cfm">
</cfcatch>
</cftry>
</cffunction>

Now access the webroot again.. The install wizard should appear as expected. At this point you can uncomment the onError handler and reupload. Everything should work fine then.

What the hell is going on here then? It could be just me who this works for but I'd be interested to hear from anyone else who has success with this fix. I am using Coldfusion MX 7.

My local development server running CF8 has no issues.

Comments
Laura's Gravatar Hi James,
Does that only happen during install? Can you re-enable the onError function after installing?
# Posted By Laura | 5/7/09 5:37 AM
James Allen's Gravatar Hi Laura,

It's really weird. As soon as onError is commented out the install procedure beings wihout error. At that point I was able to uncomment the handler and the installation carries on working.

It really makes no sense. It's as if it's a block to running the install but once the install has been loaded once (even if not completed) everything works fine when onError is added back.

I really can't explain it though would like to know if it affects other people in case it's just on my hosting..
# Posted By James Allen | 5/7/09 11:14 AM
Laura's Gravatar I don't know what it is, never seen that myself. I'm pretty sure it has to do with some setting in sandboxed CF installs. Sometimes the host can help with that by allowing certain things on the directory.
# Posted By Laura | 5/8/09 9:10 PM
James Allen's Gravatar It really doesn't make any sense does it. Certainly something I've never seen before in my 7 years of Coldfusion.
Fails with the onError handler in place but once removed it works.. But then continues to work when the handler is put back..
Bizarre.. Hopefully this fix will help others deploying your excellent blog system on CF7.
I must get my weight loss blog designed this weekend so I can finally launch it with MangoBlog.
# Posted By James Allen | 5/8/09 9:40 PM
© 2010 James Allen | Contact Me
This blog runs on the awesome power of BlogCFC - created by Raymond Camden. This blog is running version 5.9.