JBoss 7 Multiple root context web applications JBoss 7 Multiple root context web applications apache apache

JBoss 7 Multiple root context web applications


I think that the problem is that you've defined the same context root for the two applications. You can't have two applications with the same context root at the sametime. One possible solution would be to define a different context for each application (/foo and /bar respectively), and use the ProxyPass directive in each Apache virtualhost.

<VirtualHost *:80>        ServerAdmin     foo@bar.com        ServerName      www.foo.com        ...        ProxyPass         /     http://yourjbossserver:port/foo/        ProxyPassReverse  /     http://yourjbossserver:port/foo/</VirtualHost *:80><VirtualHost *:80>        ServerAdmin     foo@bar.com        ServerName      www.bar.com        ...        ProxyPass         /     http://yourjbossserver:port/bar/        ProxyPassReverse  /     http://yourjbossserver:port/bar/</VirtualHost *:80>

This way you could access your applications directly through the addresses: www.bar.com and www.foo.com, respectively. (Notice that if you have an Apache acting as a proxy, and using it's own virtualhosts, there is no need to define JBoss virtualhost).

A simple but complete example would be (in this case I've configured the jboss jmx-console, running in the same machine as the apache, to be accessible from www.foo.com):

<VirtualHost *:80>    ServerName www.foo.com    ProxyPass         /     http://localhost:8080/jmx-console/    ProxyPassReverse  /     http://localhost:8080/jmx-console/</VirtualHost>

Notice that you need to add a backslash at the end of the address.


It was just enough to add foo to my configuration, now working good with mod_jk. I blogged about it: http://fabiobozzo.wordpress.com/2013/02/25/multiple-web-applications-with-jboss-and-apache/


actually the way he had it is fine. no need for using proxy if he doesn't want. The missing piece to the original config is that he never mentioned that alias in the jboss-web.xml.

<jboss-web>   <security-domain>java:/jaas/foo</security-domain>   <context-root>/</context-root>   <virtual-host>www.foo.com</virtual-host></jboss-web>

and in the second app

<jboss-web>   <security-domain>java:/jaas/foo</security-domain>   <context-root>/</context-root>   <virtual-host>www.bar.net</virtual-host></jboss-web>

and get rid of that default-web-module tag. you are creating a paradox with that mess. you either go to one or the other.. not both. that is for when you don't have the alias mapped.