If you're working with ColdFusion 10's new REST implementation and experiencing 404 errors with Apache when trying to call your services, chances are your server is misconfigured. See this blog post for a complete step-by-step on how to configure multiple instances of ColdFusion 10 with Apache virtual hosts. It's relevant even if you only have a single instance of ColdFusion 10.
To the specific problem at hand, is how ColdFusion 10 and Tomcat handle mappings between services such as REST and ColdFusion (Tomcat) instances. There's a properties file called uriworkermap.properties that handles this:
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
/cfformgateway/* = cfusion
/CFFormGateway/* = cfusion
/flex2gateway/* = cfusion
/flex2gateway = cfusion
/cffileservlet/* = cfusion
/CFFileServlet/* = cfusion
/cfform-internal/* = cfusion
/flashservices/gateway/* = cfusion
/flex-internal/* = cfusion
/rest/* = cfusion
/*.cfml/* = cfusion
/*.mxml = cfusion
/*.as = cfusion
/*.cfm = cfusion
/*.cfm/* = cfusion
/*.swc = cfusion
/*.cfml = cfusion
/*.cfc = cfusion
/*.cfc/* = cfusion
/*.cfr = cfusion
/*.cfswf = cfusion
/*.sws = cfusion
/*.jsp = cfusion
/*.hbmxml = cfusion
1/cfformgateway/* = cfusion
2/CFFormGateway/* = cfusion
3/flex2gateway/* = cfusion
4/flex2gateway = cfusion
5/cffileservlet/* = cfusion
6/CFFileServlet/* = cfusion
7/cfform-internal/* = cfusion
8/flashservices/gateway/* = cfusion
9/flex-internal/* = cfusion
10/rest/* = cfusion
11/*.cfml/* = cfusion
12/*.mxml = cfusion
13/*.as = cfusion
14/*.cfm = cfusion
15/*.cfm/* = cfusion
16/*.swc = cfusion
17/*.cfml = cfusion
18/*.cfc = cfusion
19/*.cfc/* = cfusion
20/*.cfr = cfusion
21/*.cfswf = cfusion
22/*.sws = cfusion
23/*.jsp = cfusion
24/*.hbmxml = cfusion
What you can see here is all the mappings between the various ColdFusion services and the default cfusion instance.
The crux of the issue is that you must explicitly declare the uriworkermap.properties file in each Apache virtual host, including the default via a directive called JkMountFile. It looks like this:
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
JkMountFile "C:\ColdFusion10\config\wsconfig\1\uriworkermap.properties"
1JkMountFile "C:\ColdFusion10\config\wsconfig\1\uriworkermap.properties"
Here's an example of what that looks like for the default virtual host in Apache:
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
# Load mod_jk module
LoadModule jk_module "C:\ColdFusion10\config\wsconfig\1\mod_jk.so"
# Where to find workers.properties
JkWorkersFile "C:\ColdFusion10\config\wsconfig\1\workers.properties"
# Where to put jk logs
JkLogFile "C:\ColdFusion10\config\wsconfig\1\mod_jk.log"
# Where to put jk shared memory
JkShmFile "C:\ColdFusion10\config\wsconfig\1\jk_shm"
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
AddHandler jakarta-servlet .cfm .cfml .cfc .cfr .cfswf
<Files ~ ".hbmxml$">
Order allow,deny
Deny from all
</Files>
<VirtualHost *:80>
ServerName localhost
DocumentRoot C:/_web/cf10/cfusion/localhost/wwwroot
ErrorLog c:/_web/logs/cfusion-localhost.log
JkMountFile "C:\ColdFusion10\config\wsconfig\1\uriworkermap.properties"
<Directory "C:/_web/cf10/cfusion/localhost/wwwroot">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Alias /CFIDE "C:\ColdFusion10\cfusion\wwwroot\CFIDE"
<Directory "C:\ColdFusion10\cfusion\wwwroot\CFIDE">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
1# Load mod_jk module
2LoadModule jk_module "C:\ColdFusion10\config\wsconfig\1\mod_jk.so"
3# Where to find workers.properties
4JkWorkersFile "C:\ColdFusion10\config\wsconfig\1\workers.properties"
5# Where to put jk logs
6JkLogFile "C:\ColdFusion10\config\wsconfig\1\mod_jk.log"
7# Where to put jk shared memory
8JkShmFile "C:\ColdFusion10\config\wsconfig\1\jk_shm"
9# Set the jk log level [debug/error/info]
10JkLogLevel info
11# Select the timestamp log format
12JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
13
14AddHandler jakarta-servlet .cfm .cfml .cfc .cfr .cfswf
15
16<Files ~ ".hbmxml$">
17Order allow,deny
18Deny from all
19</Files>
20
21<VirtualHost *:80>
22ServerName localhost
23DocumentRoot C:/_web/cf10/cfusion/localhost/wwwroot
24ErrorLog c:/_web/logs/cfusion-localhost.log
25
26JkMountFile "C:\ColdFusion10\config\wsconfig\1\uriworkermap.properties"
27
28<Directory "C:/_web/cf10/cfusion/localhost/wwwroot">
29 Options Indexes FollowSymLinks
30 AllowOverride None
31 Order allow,deny
32 Allow from all
33</Directory>
34
35 Alias /CFIDE "C:\ColdFusion10\cfusion\wwwroot\CFIDE"
36
37 <Directory "C:\ColdFusion10\cfusion\wwwroot\CFIDE">
38 Options Indexes FollowSymLinks
39 AllowOverride None
40 Order allow,deny
41 Allow from all
42 </Directory>
43</VirtualHost>
Note that this is done in the mod_jk.conf file by default. This is the file that CF 10 creates and includes via your httpd.conf file by default. You don't have to use mod_jk.conf if you don't want to, but you must make sure that the various mod_jk directives are called and that JkMountFile is specified for each virtual host you setup.
Ensuring a JkMountFile directive for each virtual host should resolve the majority of your 404 errors when configuring ColdFusion 10 rest services with Apache.
5/30/12 2:47 PM
Hey Rob,
Great writeup. This looks like the problem I'm running into using cfimage and writeToBrowser. I see 404s looking for /CFFileServlet which I guess is a mapping to the temporary location of files used by cf. I'll have to dig into my configuration to make sure things are pointing in the write direction.
6/6/12 10:29 AM
Mike,
The documentation on all of this is thin (and spread out) at best. I had to do a lot of digging during the beta to figure how all of the pieces fit together.
6/21/12 9:05 AM
Guess what? This issue also impacts generating CAPTCHAs. When I converted my server to CF10 and Apache, I didn't worry about this as I wasn't doing any REST demos. Turns out though that this fix will correct CAPTCHAs not showing up as well.
10/20/12 1:27 AM
What about with IIS? I'm having the same symptom of 404 errors at /flashservices/gateway but am not using Apache.
Also is the JRunScripts virtual directory obsolete with CF10? Tried adding that but it didn't make a difference. Remoting is enabled.
3/7/13 8:13 PM
Thanks, Rob. Instructions were perfect and not only did it fix the flex2gateway, it got my server monitor in the admin working. Bonus.
3/8/13 4:06 PM
Jen, glad you found the post useful!
4/3/13 12:15 PM
I'm attempting to use the new REST services in CF10 on IIS 7.5 and am having the same 404 issue (I think).
I've created a simple "hello world" type rest service, but every attempt to consume via url returns a 404. Is there a IIS solution for this issue?