I have ColdFusion 9.0.2 and Java 1.6.0_29. I'm trying to use the java loader project to compile java code but I am receiving this error.
package javax.servlet.http does not exist import
javax.servlet.http.HttpServletRequest;
However, the javax.servlet.http package seems to be there already b/c I can execute this code without error:
<cfset obj = createObject("java","javax.servlet.http.HttpServletRequest")>
<cfdump var="#obj#">
I've tried downloading the jar for javax.servlet.http and adding it to CF (paste in C:\ColdFusion9\runtime\lib and restart cf service) but it doesn't make any difference. Is an older version of this package included in a jar that is part of CF or something?
Yep. ColdFusion itself runs as a servlet (essentially). So the javax.servlet library is already included in the main CF class path, which is why the createObject()
call works. However, the JavaLoader does not load the CF class path by default.
Parameter: loadColdFusionClassPath
Defaults to:
false
Loads the ColdFusion libraries with the loaded libraries. This used to be on by default, however now you must implicitly set it to be
true
if you wish to access any of the libraries that ColdFusion loads at application start up.
Try setting loadColdFusionClassPath = true
. Adding the javax.servlet jar file to the loadPaths
array may work as well.