1 2 Previous Next 17 Replies Latest reply: Oct 11, 2012 6:01 AM by Wolf-Dieter Fink RSS

How to get JBoss and Apache to work together

Josh Walker Newbie

I have JBoss 5 loaded on a Win2k8 box along with Apache 2.2.14 and Coldfusion 9. I believe I'm having issues with Apache and JBoss not working together or set up correctly. What is the best way to set them up? I've read mod_jk is the way to go then others say mod_proxy. I've tried both but with no luck.

We use JRun on our production servers and are thinking of switching to JBoss. JRun is fairly easy to set up with Apache, just load the module and you're pretty much set. Is there an easy way to get these two working together?

I'm new to JBoss, thanks for any help :)

  • 1. Re: How to get JBoss and Apache to work together
    Robert Freund Newbie

    JBoss and Apache do play well together! Your on a Win box. So you probably have a setup similar to c:/jboss5 and c:/apache. Now you probably want to get jboss running (at least) forward listening on port 80. You are correct. Choose either mod_jk or mod_proxy. One way to do it.... there are many and your exact server limitations/ setup should be consulted to determine your best case scenario but for a point of getting started uncomment the mod_proxy modules... If they are not already there add them from apache...

    apache/conf/httpd.conf

    LoadModule proxy_connect_module modules/mod_proxy_connect.so
    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_http_module modules/mod_proxy_http.so
    


    and then to config it in apache/conf/httpd.conf do the following... Obviously this setup is very open ended and may not be optimal for proxy pass and such but will get jboss and apache to play nice.

    apache/conf/httpd.conf
    ProxyRequests Off
    ProxyPreserveHost On
    
    <Proxy *>
     Order deny,allow
     Allow from all
    </Proxy>
    
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/
    <Location />
     Order allow,deny
     Allow from all
    </Location>
    


    That should do it. Start apache and jboss and hit localhost at port 80.

    Hope that helps.

  • 2. Re: How to get JBoss and Apache to work together
    Robert Freund Newbie

    A quick word on proxy vs ajp. I noticed some weird behavior myself when using mod_ajp as opposed to mod_proxy when it comes to jboss-native / APR and have found that mod_proxy seems to generally work more consistent. But if Comet / APR sort of setups is not the concern then ajp works flawlessly as well.

  • 3. Re: How to get JBoss and Apache to work together
    Josh Walker Newbie

    Thanks for the reply!

     

    I must still not have something configured correctly because now with all that setup I get the nice 404 error when I point the browser to localhost. If I comment it out I can get the It Works! page from Apache but if I try and hit a coldfusion page it will just show all the code.

     

    Anyway, here are my config files.

     

    httpd.conf

    LoadModule proxy_module modules/mod_proxy.so
    #LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
    #LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
    LoadModule proxy_connect_module modules/mod_proxy_connect.so
    #LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
    LoadModule proxy_http_module modules/mod_proxy_http.so
    
    ProxyRequests Off
    ProxyPreserveHost On
    
    <Proxy *>
     Order deny,allow
     Allow from all
    </Proxy>
    
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/
    
    <Location />
     Order allow,deny
     Allow from all
    </Location>
  • 4. Re: How to get JBoss and Apache to work together
    Josh Walker Newbie

    I've also seen where people have added the host name and virtual-host tag to their server.xml and jboss-web.xml files. Do I need to do that as well?

  • 5. Re: How to get JBoss and Apache to work together
    Robert Freund Newbie

    First check to make sure you are indeed listening on ports 80 and 8080. cmd>netstat -an. You should be listening on these ports.

    Also not sure about Coldfusion specifics but shouldn't your config for jboss-web exist in WEB-INF as opposed to web.inf...!

    Next I would check the root of Jboss on start. You should be able to bring up Welcome To JBoss from http://localhost. If that comes up then you know you are setup right and it's an application problem and not a jboss / apache problem. So remove your <context-root>/</context-root> and the app will live at the http://localhost/cfusion/.

    Also check nothing else is listening on those ports (other servers etc...).

    And lastly, make sure you indeed have those modules installed.

    You can add virtual-host to the jboss-web but generally you only need that if you have mutliple domains etc... so if you are accessing it from a different domain... ie devmktgweb.fullsail.com then add that virtual-host to your jboss-web.

    But first make sure jboss and apache work together... then drill down on your application specific setup.

    I see fullsail in your post above...! ROCK ON FULL SAIL!!!

  • 6. Re: How to get JBoss and Apache to work together
    Josh Walker Newbie

    Yes, both ports 80 and 8080 are listening and the config is in web-inf...that was a typo on my part :) Nothing else is listening on those ports.

     

    JBoss comes up just fine, I can get to the admin and web console with no problem. I deleted the root.war and added the <context-root>/</context-root> to the WEB-INF folder under cfusion. I can also get to the CF admin just fine as well.

     

    All I'm trying to do get a helloworld.cfm file to parse out and I know this will sound very newbie, but where would I place the coldfusion pages? Would everything go inside the cfusion.war folder in the JBoss directory?

     

    For example in my Apache config I have the DocumentRoot and Directory set to C:/domains. Inside that folder are some test CF sites. If I try to hit devmktgweb.fullsail.com the index.html comes up fine but if I try to get a CF page to load it just shows me the code and not the awesome Hello World! that I would love to see.

     

    I've tried changing the DocRoot to the cfusion folder under JBoss and can hit the CF page and it works but from outside the box it's a no go.

     

    There will be multiple different domains on this box for the developers to test their different sites so there will be different virtual hosts configured. But I just have one site setup and just need one little Hello World!

  • 7. Re: How to get JBoss and Apache to work together
    Robert Freund Newbie

    In short.. yes... your files go in the cfusion.war

    Generally, you place your files in the directory (.war) you are creating. When you place a .war in jboss/server/default/ it will be registered as an application and accessible at the location unless you specify otherwise in the jboss-web.xml file. Every application has WEB-INF which is a standard java web application deployment descriptor folder where inside you'll have your web.xml. So your application context (in your case folder) would be http://localhost/cfusion. Now that gets us to the file. Your individual pages exist inside the .war which is your application on the server. So you would have a setup like:
    >cfusion.war
    >>WEB-INF
    >>CFIDE
    >>META-INF
    >>helloworld.cfm

    Any file you want to read should be in the application context. You generally don't need to and shouldn't point your apache docRoot at this folder. By forwarding to jboss, jboss-web is more then capable of handling the request. The DocRoot in the case of any app deployed in Jboss just won't be used - instead the application your working with will be targeted which is probably the desired behavior.


    So in your case here's how your setup should work.

    Apache with the proxy_mods installed. The directoryRoot of apache is irrelevant because you are not using it. Instead you are forwarding these requests onto your application. Your j2EE Web application is the cfusion.war. This gets targeted and picked up by requests to http://localhost because in your jboss-web.xml you told it to act on the root with : <context-root>/</context-root>.

    At this point your coldfusion server application is live at http://localhost. Now.. the actual Website Applications you intend to build will live inside this main cfusion.war directory... which is providing you coldfusion inside a standard J2EE application server. Place all your coldfusion files in the cfusion.war directory or subdirectory's.

    Hope that helps!

  • 8. Re: How to get JBoss and Apache to work together
    Josh Walker Newbie

    Robert, thank you so much for your help...everything finally works! I also noticed that I was missing some config lines out of the run.bat so I added:

     

    set CF_LIB_PATH=JBOSS_DEPLOY_DIR\cfusion.ear\cfusion.war\WEB-INF\cfusion\lib
    set PATH=%PATH%;%CF_LIB_PATH%

    set CF_LIB_PATH=%CF_LIB_PATH%;CF_WEBAPP_ROOT\WEB-INF\cfusion\jintegra\bin;CF_WEBAPP_ROOT\WEB-INF\cfusion\jintegra\bin\international

     

     

    Now the trick is to get different sites to work on the same box. If I were to add another CF site would I just create another folder under the cfusion.war directory? Or would I have to make another .war folder under the deploy directory and copy over the cfusion.war and META-INF folders and go from there?

     

    I have the vhosts set in Apache, would I have to add something like the following to the server.xml file under JBoss?

     

     

     

    <Host name="domain" autoDeploy="false" deployOnStartup="false" deployXML="false">
        <Alias>www.first-domain-name.com</Alias>

        <Valve className="org.apache.catalina.valves.AccessLogValve"
            prefix="things" suffix=".log" pattern="common"
            directory="${jboss.server.home.dir}/log"/>

        <DefaultContext cookies="true" crossContext="true" override="true"/>
    </Host>

    <Host name="domain2" autoDeploy="false" deployOnStartup="false" deployXML="false">
        <Alias>www.second-domain-name.com</Alias>

        <Valve className="org.apache.catalina.valves.AccessLogValve"
            prefix="things" suffix=".log" pattern="common"
            directory="${jboss.server.home.dir}/log"/>

        <DefaultContext cookies="true" crossContext="true" override="true"/>
    </Host>

     

     

     

    Thanks again for all the help!
  • 9. Re: How to get JBoss and Apache to work together
    Robert Freund Newbie
    Yeah. You should add the server.xml hosts you indicated for each vhost. Generally.... you should use a seperate .war for each isolated site you are going to deploy. Context is important and if you're developing multiple isolated sites you should deploy each as a seperate war.
  • 10. Re: How to get JBoss and Apache to work together
    Josh Walker Newbie

    I'm still having problems getting multiple instances of Coldfusion to run. If I have 2 CF sites in the deploy directory and start up JBoss, only one will start and the other fails to start with the following error:

     

    java.lang.SecurityException: Seed must be between 20 and 64 bytes. Only 8 bytes supplied.

     

    I've searched around online and they say to add the following line to your java.args in your jvm.config, but I think that's part of JRun because I can't find that file anywhere.

    -Dcoldfusion.disablejsafe=true

    I think I have all the virtual hosts, etc set up correctly....any idea on what to do with that error?

  • 11. Re: How to get JBoss and Apache to work together
    Robert Freund Newbie

    Might want to check this if you have not already. I see some things in there that may help.

    http://help.adobe.com/en_US/ColdFusion/9.0/Installing/WSc3ff6d0ea77859461172e0811cdec18c28-7fbd.html

  • 12. Re: How to get JBoss and Apache to work together
    Josh Walker Newbie
    Yeah, I followed that article when setting up JBoss and CF9 so I'm kind of at a loss on what to do next...
  • 13. Re: How to get JBoss and Apache to work together
    Josh Walker Newbie

    So I totally missed that last paragraph from the article. I edited the run.bat.

     

    +Original+

     

    if "x%JAVA_OPTS%" == "x"

      (set "JAVA_OPTS=-Dprogram.name=%PROGNAME%")

      else

      (set "JAVA_OPTS=-Dprogram.name=%PROGNAME% %JAVA_OPTS%")

     

    +New+

     

    if "x%JAVA_OPTS%" == "x"

      set "JAVA_OPTS=-Dcoldfusion.disablejsafe=true")

    else

      (set "JAVA_OPTS=-Dcoldfusion.disablejsafe=true %JAVA_OPTS%")

     

    Now both CF instances are running in JBoss but I still can't get to the second site. My config's are as follows:


    Apache vhosts


    <VirtualHost *:80>
       ServerName devmktgweb.mysite.com
       ServerAlias devmktgweb.mysite.com
       ProxyPass / ajp://devmktgweb.mysite.com:8080/
       ErrorLog "logs/devmktgweb.mysite.com-error.log"
       CustomLog "logs/devmktgweb.mysite.com-access.log" common
    </VirtualHost>

    <VirtualHost *:80>
        ServerName brazil-dev.mysite.com
        ServerAlias brazil-dev.mysite.com
        ProxyPass / ajp://brazil-dev.mysite.com:8080/
        ErrorLog "logs/brazil-dev.mysite.com-error.log"
        CustomLog "logs/brazil-dev.mysite.com-access.log" common
    </VirtualHost>


    Under the JBoss deploy directory I have brazil.ear and cfusion.ear.


    C:\jboss-5.1.0.GA\server\default\deploy\brazil.ear\brazil.war\WEB-INF
    <jboss-web>
         <context-root>/brazil</context-root>
         <virtual-host>brazil-dev.mysite.com</virtual-host>
    </jboss-web>

    C:\jboss-5.1.0.GA\server\default\deploy\cfusion.ear\cfusion.war\WEB-INF
    <jboss-web>
    <context-root>/</context-root>
    </jboss-web>


    server.xml

    <Host name="devmktgweb.mysite" autoDeploy="false" deployOnStartup="false" deployXML="false">
    <Alias>devmktgweb.mysite</Alias>
    </Host>


    <Host name="brazil-dev.mysite" autoDeploy="false" deployOnStartup="false" deployXML="false">
    <Alias>brazil-dev.mysite</Alias>
    </Host>

    If I go to localhost:8080 I can get the test CF page to come up just fine. I modified my hosts file on my external computer and I can get to devmktgweb.mysite.com just fine. However brazil-dev.mysite.com gives me a 404 error and I can't get to it on the local machine by going to localhost:8080/brazil.


    I know there's something I'm missing but I'm just not sure what I need to change or add.
  • 14. Re: How to get JBoss and Apache to work together
    erasmo2 marciano2 Master

    You have a error here, in this line code

     

    ProxyPass / ajp://devmktgweb.mysite.com:8080/

     

    You are doing to work JBoss and Apache with ajp.

     

    The port of defaul ajp is 8009

     

    Try ProxyPass / ajp://devmktgweb.mysite.com:8009/

1 2 Previous Next