Avoid those "hidden" features
I've said more than once that folks should avoid using hidden, undocumented features in ColdFusion. This warning applies especially to the ServiceFactory. Did you know that in ColdFusion 8 you can restrict access to the factory? In the settings page there is a new option:
Disable access to internal ColdFusion Java components
Disables the ability for CFML code to access and create Java objects that are part of the internal ColdFusion implementation. This prevents an unauthenticated CFML template from reading or modifying administration and configuration information for this server.
So what happens when this is enabled? Consider this simple code:
<cfset monitor = createObject("java", "coldfusion.runtime.RequestMonitor") />
With the above option disabled, it runs fine, but when turned on, you will get:
Permission denied for creating Java object: coldfusion.runtime.RequestMonitor.
Access to Java objects in the ColdFusion package has been disabled by the administrator.
So just keep it in mind when developing. I won't deny that I've used these internal objects myself in the past, but now I avoid them like the plague. Almost anything you need (almost) is available via the Admin API anyway.
Comments
lib_cfusion.cfc
|_ lib_cfusion_8.cfc
. |_ lib_cfusion_8_admin.cfm
You could just have two levels really, it's up to you. The functions used are in the lib_cfusion.cfc : eg <ctmmffdump> cfscript replacement - which has difference attributes from v7 to v8.
I'll post more on my blog later today (AU time)
This has nothing to do with coding practices. It's really about just following the "rules", the rules being the docs.
You are basically saying it IS ok to use the admin objects, but only if you run them in an environment that matches the CF version. I say it is never ok and should be voided. Period.
Don't know what you're talking about Ray....
*hides under a rock*
;o)
Permission denied for creating Java object: coldfusion.server.ServiceFactory.
Access to Java objects in the ColdFusion package has been disabled by the administrator.
All because of the following line of code:
<cfset factory = createObject( "java", "coldfusion.server.ServiceFactory" )>
Now, mind you, this is the first sample application you will get from Adobe regarding database connectivity between Flex 3 and Coldfusion and most places, it won't run. Not to mention, my host says that it supports all tags except for CFExecute and CFRegistry which would lead you to believe CFObject will work for any circumstances.
http://brad.melendy.com/projects/flex/DataTest4/em...
This generates an error on my shared host but not on my localhost.
However, it works great when you hit the Flex app:
http://brad.melendy.com/projects/flex/DataTest4/Da...
So fooie on me. I'm just glad it works. :-)


Instead we should be advocates for better coding practices. For example instead of saying 'don't use the admin objects', you should instead build version specific libraries for using the admin api and alike:
lib_cfusion.cfc -> the library you use to run coldfusion specific functions
lib_bdragon.cfc -> the library you use to run bd specific functions
lib_cfusion_7.cfc -> uses the coldfusion 7 libraries
lib_cfusion_8.cfc -> uses the coldfusion 8 libraries
lib_cfusion_8_admin.cfc - version 8 admin api library.
etc
This way if the api changes all you need to do is create a cfc for the new version and pass the version as part of the arguments for each function.
This is the way a lot of javascript libraries work, why not implement it in coldfusion?