March 7, 2010

Deploy ColdFusion 8/9 on Glassfish v3

Deploying ColdFusion 8/9 on Sun Glassfish 3 is not much different than it is on IBM WebSphere 7 AS. Except, imho, it is far more optimal, because it takes much less resources (especially if it is setup for dev) and cost nothing. I did this on Win7 platform, but it looks completely the same on Linux platforms. So, let's move.

Application Server Setup
  • Download ColdFusion 8/9 Developer Edition from
  • Prepare ColdFusion 8/9 for J2EE deployment: Run setup file -> J2EE Configuration ->  EAR File -> ContextRoot: cfusion -> enable RDS. More details on Just  prepare and don't expand the EAR file.
  • Be sure you have installed JDK. For latest version go to If you develop under Eclipse and while you are there, download "GlassFish Tools Bundle for Eclipse" too. It is not necessary for CF development, but gives you full control over application server from your IDE, which is cool.
  • Install Sun GlassFish Enterprise Server v3. Go to and download it. Installation procedure is very simple. Change port numbers if you want, but remember it, because you'll need it.
  • Deploy ColdFusion 8/9 on GlassFish: Open GlassFish Administrator Console -> Applications -> Deploy... -> Packaged file to be uploaded...-> /cfusion.ear -> OK. You've prepared EAR file in step 1.
  • Open CF Admin for the first time. Notice that path is case sensitive. http://localhost:8080/cfusion/CFIDE/administrator/
ColdFusion Builder Setup
  • Setup GlassFish connector in Eclipse. As I said before, I think this is not necessary, but, from my experience, since I haven't installed this, CF Builder did not recognize CF Server mappings properly.
  • Setting up CF debugger. Open GF Admin Console http://localhost:4848/. Go to Configuration -> JVM Settings. You should see in "Debug Options" field -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9009. Leave it as is. If you like you can change port address (9009). In CF, usually, by default it is 5005. Check "Debug" box. Press "Save" and restart GlassFish.  Now, go CF Admin. Open Debuggin & Logging -> Debugger Settings, check "Allow Line Debugging" and set Debugger Port number to one you've set in previous step, in GF Admin Console. Press "Submit Changes".
  • Deploy test web application on CF9@Glassfish
    -> create folder "test" under ${com.sun.aas.instanceRootURI}/applications/cfusion/cfusion_war
    -> create index.cfm with "Hello World" text in it
    -> call http://localhost:8080/cfusion/test/. You should see "Hello World!" text in your browser.
  • Instead to type http://localhost:8080/cfusion/test/ all the time you can create a proxy to your project's address on apache httpd:
    -> Open httpd.conf. Enable modules:
         LoadModule proxy_module modules/
         LoadModule proxy_connect_module modules/
         LoadModule proxy_http_module modules/
    -> Include addition virtual host definitions. Uncomment line:
         Include conf/extra/httpd-vhosts.conf
  • Open /conf/extra/httpd-vhosts.conf. Add:
          <Virtualhost *:80="">
              ServerName testproj
              ProxyRequests Off
              <proxy *="">
                  Order deny,allow
                  Allow from all
              ProxyPass / http://localhost:8080/cfusion/test/
              ProxyPassReverse / http://localhost:8080/cfusion/test/

  • Add "testproj" in your hosts file. Open in any text editor /syste32/drivers/etc/hosts. At the bottom add line:         testproj
  • Now, your test app should be accessable by http://testproj
Glassfish specifics
Nice tutorial how to publish static content and virtual directories here and here.
But, what worked for me is: Glassfish 3 Console -> virtual servers -> click on "server" -> Scroll down to "Additional Properties" -> Add... -> name: alternatedocroot_1, value: from=/mydir/* dir=C:/privatedir/

Just when I finished this manual I found blog with almost the same content. 
If you find this insufficient you can go and check Kukiel's blogs:

Strange this blog did not show up when I look for "ColdFusion on glassfish" at Google, but did when I look for "Railo on Glassfish". Byah, Even Google lie from time to time ;)


Several links that might help you with GF/Apache configuration

User Guide – GlassFish v3 User Guide
and look for "Apache as a front end to GlassFish using mod_jk" section

Virtual Hosting using Apache and GlassFish

+ check comment 5


Sami said...

Have you tried getting multiple virtual servers working without the need for Apache on the front-end.

Marko said...

Sorry, no. Have you tried it? If you did, how is your experience? Have you had any problem? From what I read and see should be simple, but since you ask I smell it is not as it sounds :)

Sami said...

Yeah, I haven't been able to get it to work at all. So far I've read numerous blogs, whitepapers and documentation, and it looks i've hit a serious roadblock.

Rodion Bykov said...

Apache will be only act as proxy and not serve static files in this case. CF will handle more load. Also, not sure how .htaccess files will be processed. Had you such issues ? Thanks !

Marko said...

Hi Rodion,
I run GF only on my dev machine, therefore I have had no need to bother with .htacces nor apache connectors. But, luckily, I bookmarked blog where you can find how to run GF on Apache.That way, you should be able to utilize .htaccess and redistribute load (static to apache + jsp, cfml to GF).

GF3 + Apache

GF2 + Apache

In tutorial for GF3 traffic distribution is based on file location (/example dir), opposite to GF2 example where it is done by extension (JkMount /*.jsp worker1)

Don't miss to check comments. Obviously installation is not going smoothly as it is usual :) If you decide to go this way, I would appreciate if you would share your experience.