11 Replies Latest reply on Nov 2, 2010 4:24 AM by aartemov

    JBoss 5.1.0.GA + ColdFusion 9 set up

    wiwwy

      I have ColdFusion installed as an EAR file in $JBOSS_HOME/server/default/deploy/cfusion.ear -- on local disk.  I would like to place the custom CF application files on a shared file system (e.g. /apps/mycfapp) outside of the CF application root: $JBOSS_HOME/server/default/deploy/cfusion.ear/cfusion.war.  With JRun, you could map to a different resource path by modifying cfusion.ear/cfusion.war/WEB-INF/jrun-web.xml.

       

      Ex:

      <virtual-mapping>

         <resource-path>/*</resource-path>

         <system-path>/apps/mycfapp</system-path>

      </virtual-mapping>

       

      Is there a way to modify/specify the path to the custom CF application files when deployed inside JBoss?  Or is this not possible at all and all the files must be deployed locally to the $JBOSS_HOME/server/default/deploy/cfusion.ear/cfusion.war directory?

       

      Desired behavior: When I access http://www.mydomain.com/cfusion/index.cfm, ColdFusion would load index.cfm from /apps/mycfapp/index.cfm instead of $JBOSS_HOME/server/default/deploy/cfusion.ear/cfusion.ear/index.cfm.

        • 1. Re: JBoss 5.1.0.GA + ColdFusion 9 set up
          misterwoody

          This is something I'm interested in doing as well, as part of the process to migrate from JRun to JBoss based installations.

           

          The closest I've been able to get was on a Railo based project, adding in a new location for coldfusion templates.

           

          The place to start looking is in JBOSS_HOME/server/default/conf/bootstrap/profile.xml which holds a section related to applicationURIs that can hold a list of locations where you want to deploy applications from.

           

          I don't have access to the project currently, but from memory I had to create a folder with a .war extension (say myapp.war) and use that as the context when browsing - so http://localhost:8080/myapp/index.cfm would be the appropriate location (or possibly /cfusion/myapp/index.cfm dependent on the initial context).

           

          Hope this is enough to get you started, but I'll try to dig into more details when I'm back in work and have server access.

           

          Regards

          • 2. Re: JBoss 5.1.0.GA + ColdFusion 9 set up
            misterwoody

            A little more on this one ...

             

            My addition to the profile.xml file, section on applicationURIs points to a folder containing the .war named application, and as per the documentation it has to be in URI format - so if you're on windows you'll need something like <value>file:///d:/folder_name</value> added to the list.

             

            Then drop your (exploded) web app in that folder - I produced an image uploader and put it into a folder called uploader.war, with WEB-INF inside plus the other bits and bobs like css, images etc. You can also drop an index.cfm template in here that will form your initial page.

             

            Within the WEB-INF you ought to have a jboss-web.xml file that holds your virtual host name and a context root - read more about that in the docs.

             

            To tie that in with your jboss server, you'll need an additional host entry in the JBOSS_HOME/server/default/deploy/jbossweb.sar/server.xml file to define the virtual host.  Whatever name you put in the jboss-web.xml needs to match the host name in the server.xml.

             

            p.s. It's probably best to have your jboss instance stopped when making these changes otherwise the AS attempts to dynamically deploy them as soon as you save any files and ypu'll likely get errors.

             

            HTH

             

            Cheers

            • 3. Re: JBoss 5.1.0.GA + ColdFusion 9 set up
              aartemov

              Hello! Thank you for hint, because I have the same problem: I don't need to place CF in other folder than in standard folder for deploying, but I want to make my URL to the root of CF without additional folder names. The idea with the virtual host sems to be not making sense, because virtual-host is just for changing base site URL, such as www.mysite.com. If it is useful for you, L L, I suggest you this URL - http://www.openscope.net/2010/01/17/virtual-hosting-with-jboss/. But this way doesn't allow to change starting point to cfm-files in CF. I mean, instead of "http://mysite.com/folder1incfwar/folder2incfwar/index.cfm" I want to get http://mysite.com/index.cfm when going through browser. If you, Mister Woody, have an idea or anyone else, I would be very grateful.

              • 4. Re: JBoss 5.1.0.GA + ColdFusion 9 set up
                misterwoody

                Hi.  Quick question for you Alexander - are you fronting JBoss with a web server such as Apache or have you configured JBoss to listen on port 80 and handle the requests directly?  Thanks

                • 5. Re: JBoss 5.1.0.GA + ColdFusion 9 set up
                  misterwoody

                  Ok - I'll assume there's no web server involved as a starter.  As part of the post you mentioned on virtual hosts, it includes a value for the context-root as well as the virtual host in the jboss-web.xml file.  You can set this to just a slash, which then means you can access things like the coldfusion administrator from a url like http://my.local.website:8080/CFIDE/administrator/ or if JBoss is set to listen to port 80, remove the :8080 and you're close to what you're after.

                   

                  If you also want to deploy within the cfusion.war directory, you probably don't even need a .war extension - just put things in that directory.  The bit I'm not sure about (yet) is how to have multiple virtual hosts being served with the applications at the root - and maybe that's what you're after?

                   

                  It's probably just a variation on what has currently been discussed in this thread, I just haven't got around to testing the variations yet.

                   

                  If you are using something like apache on the front, the you open up whole new areas of investigation as you can then use rewrite rules or proxy pass to push things where you want to.  There are some interesting articles byhttp://Sean Corfield among others about setting up multiple instances, though these tend to use Mac OSX or *nix based installations which helps in that you can use symbolic links for things and use ROOT.war which has it's own special meaning.  They also tend to be about Tomcat and Railo rather than JBoss and ACF - but there are lot's of great tips in there.

                   

                  HTH.

                  Thanks

                  • 6. Re: JBoss 5.1.0.GA + ColdFusion 9 set up
                    misterwoody

                    Ok - there is an answer, at least to L L's original post.  So far I've only got this as far as using JBoss with Adobe CF 9 on port 8080 without bringing in apache as a front-end which is what I'm really after.  The scenario below will give you a local.site1 application setup on a local machine that will parse coldfusion code. Here we go step by step.

                     

                     

                    • Create a directory outside of the jboss installation directory to hold your application - I called mine d:\site1webroot.
                    • Inside this subdirectory, create another folder that will be your exploded web archive - I called mine site1.war
                    • Within this directory create a WEB-INF folder and a simple test coldfusion template testsite1.cfm for example and put in a plain text line for now
                    • Inside the WEB-INF folder create a web.xml with just a <web-app></web-app> line in it (it's not really valid or pretty but it does the job - without it your app will fail to deploy)
                    • Also inside the WEB-INF create a jboss-web.xml file with the following in

                     

                    <jboss-web>

                     

                        <virtual-host>local.site1</virtual-host>

                     

                        <context-root>/</context-root>

                     

                    </jboss-web>

                    • Now go to your JBoss installation folder and find the profile.xml file that I mentioned a few posts back - it will be in {JBOSS_HOME}/server/default/conf/bootstrap/profile.xml
                    • Open up this file to edit and within the <property name="applicationURIs"> under the line <value>${jboss.server.home.url}deploy</value> add in a new line for your directory created at the start - <value>file:///d:/site1webroot</value>
                    • Save the file and move on to the server.xml file in {JBOSS_HOME}/server/default/deploy/jbossweb.sar
                    • Towards the bottom of this file, within the engine declaration but after the default host definition add the following

                         <Host name="local.site1" autodeploy="false" deployOnStartup="false" deployXML="false">
                                 <Alias>local.site1</Alias>
                                
                                 <Valve className="org.apache.catalina.valves.AccessLogValve"
                                    prefix="local_site1_access_log." suffix=".log"
                                    pattern="common" directory="${jboss.server.log.dir}"
                                    resolveHosts="false" />
                             </Host>

                    • This will tie the declaration in the jboss-web.xml for local.site1 to this virtual host and create its own log file making things easier to track
                    • With that in place, you should now be able to start up JBoss and after the messages settle be able to browse to http://local.site1:8080/testsite1.cfm
                    • Your "Hello world" or whatever was put in place should be shown in the browser.  If you get a 404 error, check that the site1 app was correctly deployed by looking for error messages.  Before I put in the simple web.xml my app was failing to deploy so this is probably the best place to start.
                    • Having got this far - go back into the source for testsite1.cfm and add something simple to test coldfusion, a <cfoutput>#now()</cfoutput> is about as simple as it gets.
                    • If you browse to this, you'll get the code and not the parsed output as I've seen in other posts on this subject.
                    • Here's where the last piece of the puzzle comes in.  Reading through Ben Nadel's blog entry on JRun servlet errors I came across a comment by Larry C. Lyons pointing off to yet another post by Steve Brownlee on fusioncube entitled coldfusion on jboss standalone primer - and that's a cool article for those of us who are coming from a JRun background with Coldfusion who want to know why things don't work with other Java EE application servers.  The gist of it is that Adobe have been performing magic under the covers with JRun and coldfusion and web server front ends so that we are a little wrapped in cotton wool.  Read the article to get more depth (I found it well worth it) but here's the short version.
                    • Stop your JBoss server instance
                    • Take a copy of your existing jboss-web.xml file from the site1.war\WEB-INF folder as we're about to overwrite it.
                    • Copy the WEB-INF and CFIDE folders from your {JBOSS_HOME}/server/default/cfusion.ear/cfusion.war folder into the site1.war folder we created at the start - responding yes to overwrite any existing files (web.xml and jboss-web.xml in this instance).
                    • Once the copy is complete, remove the jboss-web.xml file from your WEB-INF folder and restore the backup copy you made
                    • Start the jboss server instance
                    • Once the server has started you should be able to browse to http://local.site1:8080/testsite1.cfm and the coldfusion code should be correctly parsed

                     

                    I've not tested in any great depth as yet - but the fact that a simple cfm template parses is encouraging.  It's not quite as straightforward as some of the Railo based installs I've read about, but if it works it means I have a good way forward to move towards a more up-to-date Java application server. Hopefully this will also work with the upcoming JBoss 6 release when it comes out.

                     

                    Thanks for reading - hope this helps at least one person.

                     

                    Cheers

                    • 7. Re: JBoss 5.1.0.GA + ColdFusion 9 set up
                      aartemov

                      >Hi.  Quick question for you Alexander - are you fronting JBoss with a  web server such as Apache or have you configured JBoss to listen on >port  80 and handle the requests directly?  Thanks

                       

                      I'm listening on port 80 and handle the requests directly.

                      • 8. Re: JBoss 5.1.0.GA + ColdFusion 9 set up
                        misterwoody

                        Hopefully the above will help even if it's not exactly what you're after.  All the port 8080 references can be left out for your setup.

                         

                        Thinking about this again this morning, in effect the above is similar to a manual multi instance setup of ACF on JRun where you could create a new instance under JRun, the copy the cfusion.ear folder into that instance and delete the default.ear folder.  Ben Purcell used to have an article posted about this but the links to Adobe all seem to be dead unfortunately. The nearest I was able to find was this category of dated material which includes a post on L L's original tip on JRun.

                         

                        Cheers

                        • 9. Re: JBoss 5.1.0.GA + ColdFusion 9 set up
                          aartemov

                          Thank you, Mister Woody, for such a full reply. The problem is that this way means that I should contain my cfm-file right in .war folder. But It's inconvenient, because of there's CFIDE also in that directory, which is absolutely another application and also because there could be more than one CF application. So it's logically to put my CF application in additional folder. But this folder is not .war folder an thus apparently Jboss doesn't look for files such as jboss-web.xml in WEB-INF of this folder. If not this additional folder, I had to care only about that the CFIDE doesn't load when context root of my CF application is / (I had to remove ROOT.war to make my CF app work with context-root = /). Yes, I don't understand by the time, why it doesn't load, when there's no errors in the process of deployment. But I should have CFIDE and my CF app in different folders. This is my folder structure:

                          .../cfusion.ear/cfusion.war

                          ----------------------------------myapp

                          ----------------------------------CFIDE

                          Of course instead of cfusion.wat could be d:\site1webroot\site1.war - there's no difference (I'm working on Linux gentoo).

                          I'll study web sources that you suggested.

                          • 10. Re: JBoss 5.1.0.GA + ColdFusion 9 set up
                            misterwoody

                            Okay - I think I see what you want now.  For each folder within the cfusion.war, you want a single instance of Adobe Coldfusion to deliver application services for a number of websites.  Just to double check, you want your myapp folder to be for example http://some.website/ where the index.cfm within myapp is invoked when going to that website, and have myapp2 do the same thing for http://some.other.website/.

                             

                            In my mind - that's exactly what virtual hosts is about, though to be honest I would use Apache to front end as then you can transparently proxy the back end to any directory with Apache modules I believe.  I'll need to do some further experimenting to see if I can come up with an answer - but you may want to read up on them yourself - Jamie Krug's ColdFusion blog  may be a good starting point or Sean Corfield's Architects view - let me know how you get on.

                             

                            Cheers

                            • 11. Re: JBoss 5.1.0.GA + ColdFusion 9 set up
                              aartemov

                              >Just to double check, you want your myapp folder to be for example http://some.website/ where the index.cfm within myapp is invoked when going to that website, and have myapp2 do the same thing for http://some.other.website/.

                              Yes, this is what I want.