ColdFusion 9 on GlassFish

by 8:22 AM 53 comments

Download and install java sdk ( I used 1.6.17 ) ( note you need the JDK not JRE )
Download glassFish
Download ColdFusion 8 or 9
Download Apache

I used Windows Server 2008 64bit but the process is the same for 32bit or Win 2k3.  It's also ( obviously ) different on linux or unix but not majorly.

When installing glassFish did not detect java home correctly so I provided the location via the cmd line.


The install is very straight forward I did not select anything unusual and just clicked through:

Once glassFish was installed I started the server:



Then browse to:  http://127.0.0.1:4848 to get to the admin console.


I choose to leave the admin with no authentication so it will just load to the console.

Before you look at the console we will need to create a ColdFusion war.  Run the ColdFusion installer and select "JEE Configuration"

This will produce the war file ready for deployment.  For me the output was c:\coldFusion9\cfusion.war

Now go back to the control panel.  Select "Applications" from the menu.  Then select "Deploy".  Choose a file from the local file system and leave the name as cfusion.


Once the application is deployed we can launch it by clicking launch button and you will see:

404 error's.  This is because there are no .cfm files if you went to /CFID/administrator you would would be at the CFADMIN.

I'll skip the CFADMIN and make a index.cfm:

Contaning:





Reload the Original page that was launched by clicking "Launch"

And ColdFusion 9 is running on GlassFish.

This is on port 8080 but I want it to run behind apache on port 80 without the /cfusion

Make sure IIS is not running. Install Apache.  Apache for windows come with all the modules you're likely to need but most are commented out.  Test to make sure Apache is runnign and http://127.0.0.1 should the standard message "It works".

Now we will setup the proxy.

Around line 110 of httpd.conf uncomment 2 modules mod_proxy.so and mod_proxy_connect.so



Also un-comment


Open {apacheInstallDir}\conf\extrahttpd-vhosts.conf

create a new vhostBlock


I created a dummy entry in the Windows host file so http://cf9gf resolves locally. I'll be using this as the test domain.

Restart apache and look for errors.


If there are no errors you should now be ready to proxy from apache to glassFish on port 80.


Done.

Now GlashFish is no longer listed here: http://www.adobe.com/products/coldfusion/systemreqs/ but it still works fine.

Also note the /flex2gateway works fine aswell.

53 comments:

  1. good one !

    as always very clear and simple to follow.

    Rahul.

    ReplyDelete
  2. I'm getting a 404 error with the /flex2gateway. Any ideas on that?

    ReplyDelete
  3. Nevermind, stupid error on my end.

    ReplyDelete
  4. This config coud be used with CF8 and Glasfish 2.x?

    ReplyDelete
  5. Yes it would work the same way with GF 2.

    ReplyDelete
  6. Hmm, the apache part does not work, i get an 500 error the moment i un-comment
    "Include conf/extra/httpd-vhosts.conf"

    ReplyDelete
  7. Perhaps you made a typo in the httpd-vhosts.con file. Can you paste the code?

    ReplyDelete
  8. this is what i have added to my http-vhosts.conf removed the tag smybols <>:

    virtualhost *:80
    DocumentRoot "C:\dev\cfusion"
    ServerName cfusion
    ProxyRequests Off
    proxy *
    Order deny,allow
    Allow from all
    /Proxy
    ProxyPass / http://127.0.0.1:8080/cfusion/
    ProxyPassReverse / http://127.0.0.1:8080/cfusion/
    ErrorLog "logs/cfusion.local-error.log"
    CustomLog "logs/cfusion.local-access.log" common
    /VirtualHost

    virtualhost *:80
    DocumentRoot "C:\dev\cfusion"
    ServerName railo
    ProxyRequests Off
    proxy *
    Order deny,allow
    Allow from all
    /Proxy
    ProxyPass / http://127.0.0.1:8080/railo/
    ProxyPassReverse / http://127.0.0.1:8080/railo/
    ErrorLog "logs/railo.local-error.log"
    CustomLog "logs/railo.local-access.log" common
    /VirtualHost

    ReplyDelete
  9. That looks fine. Does http://127.0.0.1:8080/cfusion/ work?

    ReplyDelete
  10. Yes http://127.0.0.1:8080/cfusion and http://127.0.0.1:8080/railo/index.cfm work without any problem

    ReplyDelete
  11. This line causes the 500 error:
    ProxyPass / http://127.0.0.1:8080/cfusion/
    Without it the default Apache site will be displayed but the url rewrite does not work

    ReplyDelete
  12. mod proxy must not be available. In httpd.conf un comment these lines:

    LoadModule proxy_module modules/mod_proxy.so

    LoadModule proxy_connect_module modules/mod_proxy_connect.so

    ReplyDelete
  13. They are un-commented. I use Apache 2.2.14...

    ReplyDelete
  14. Stupid me. I had to un-comment the mod_proxy submodule for http.

    ReplyDelete
  15. LoadModule proxy_http_module modules/mod_proxy_http.so

    Oh yeah this is needed aswell. I forgot to include that in the post.

    ReplyDelete
  16. have you tried to access the coldfusion adminstrator interface?

    I have followed your guide and see the server dump when i enter this into the browser:

    http://adobe/index.cfm

    But when i try to get into the CF9 Admin Interface:
    http://adobe/CFIDE/administrator/index.cfm

    I see the login page without images and when i enter my password i am redirected to:
    http://adobe/cfusion/CFIDE/administrator/enter.cfm

    The only difference to your setup is the ServerName adobe instead of cf9gf. What's going on?

    Railo works without any problem!

    ReplyDelete
  17. Yep that happened to me aswell. I just used 127.0.0.1:8080/cfusion/cfide/administrator to get the un-broken admin.

    ReplyDelete
  18. Hey, i use this now in my httpd-vhosts.conf.

    ServerName adobe
    RewriteEngine On
    RewriteOptions Inherit
    RewriteRule ^/(.*) http://127.0.0.1:8080/$1 [P,L]
    ProxyPassReverse / http://127.0.0.1:8080/
    ProxyPreserveHost On

    Now i can reach the CF9 Admin through http://adobe/cfusion//cfide/administrator/index.cfm and it works.

    Any idea how to tell railo and adobe to share the same contex root on a windows platform?

    ReplyDelete
  19. You can't I wanted to ideally do the same thing so I could use the exact same code for both CF9 and Railo but I wasn't able to do it.

    ReplyDelete
  20. I have added this mapping to both:

    /dev c:/dev/cfusion/

    Railo understands this but Adobe does not resolve the mapping!?

    ReplyDelete
  21. @Paul - great write up, got this working in about 1/3 the time I expected.

    One question, though. I like to set up my dev sites as their own 'domain' in Apache - like myproject.dev and point the vhost to the dir where the files for that project are kept. it seems that setting up Glassfish with Apache the way to outlined that is not possible (or at least, not obvious). Can you shed some light on how to do this...if its even possible?

    ReplyDelete
  22. @Scott I would deploy a 2nd instance of ColdFusion war and set the virtual host to that. Although this is going to chew up RAM. There are ways to make Tomcat server wide but I'm not sure how to with Glassfish. If I come up with something I'll follow up.

    ReplyDelete
  23. Hello,

    thanks for explanations!

    Did you find way to move wwwroots for CF9 and Railo out of glassfish installation directory ? Like having Apache's /htdocs folder common storate for Apache, CF and Railo ? In Resin or Tomcat I'd fix clause for Railo... Don't want to have 3 different folders for development code :-)

    ReplyDelete
  24. @Rodion No I haven't. I'm not sure its possible to do that perhaps on linux with symlinks

    ReplyDelete
  25. @Paul, there's solution for document root problem: http://www.marceble.com/2009/07/virtual-directories-in-glassfish/

    ReplyDelete
  26. @Rodion Wow thanks. That's a great solution.

    ReplyDelete
  27. How about cf9, glashfish and iis7?

    ReplyDelete
  28. I need iis for more reason.

    ReplyDelete
  29. @Anonymous You can use a re-write rule for IIS7 or see if sun have connectors ( like tomcat ) for IIS. I havn't had to do this so I'm not sure but my first thought woudl be to simple re-wriet all .cfm/cfc requets to glassfish.

    ReplyDelete
  30. Hi Paul,

    I've been trying to get ColdFusion Developer 9 deployed onto GlassFish 3.1.1 (on Windows 2003 64-bit), and found your post above. I've tried deploying CF9 both as a WAR and as an EAR, and can't get either to deploy on GF 3.1.1. I get errors during the deployment, with a NoClassDefFoundError on flex.server. Did you run across that? Is there something besides ColdFusion WAR itself that needs to be installed before trying to deploy the WAR?

    Thanks,
    Jim

    ReplyDelete
  31. @Jim. No I never ran into the error. I haven't used GlassFish for at least 12 months now. I didn't need to do anything else other then what was described in this post. Sorry I can't be of any more help/

    ReplyDelete
    Replies
    1. @Paul,

      FYI, I was able to deploy CF8.01 as as WAR on GF 3.1.1. That went smoothly, unlike trying both the WAR and EAR for CF9 :(...

      Thanks,
      Jim

      Delete
  32. Subsidiary showcasing happens to be a standout amongst the most advantageous, compelling and furthermore profoundly lucrative internet promoting technique, and offers site proprietors an exceptional savvy methods for acquiring additional cash. These projects are fundamentally gone for driving more activity to online vendors that take an interest in a given offshoot advertising program, which can normally prompt more income age for them. More Information

    ReplyDelete
  33. Packers and Movers Gurgaon - Best Movers and Packers in Gurgaon offers home, office and local shifting services at affordable price. Call 07835880002, Visit @
    Packers and Movers Gurgaon

    ReplyDelete