JBoss 7 Multiple Root Contextual Web Applications

I need to set up two websites, www.foo.com and www.bar.net in my Apache2 + JBoss7.1 environment.

Example configuration of Apache sites (they are similar to each other, except for the site name):

<VirtualHost *:80>
        ServerAdmin     foo@bar.com
        ServerName      www.foo.com

        DocumentRoot /var/www/foo
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/foo>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        SetEnvIf Request_URI "/photos/*" no-jk
        JkMount / ajp13
        JkMount /* ajp13

</VirtualHost>

      

In JBoss standalone.xml I have:

<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">
            <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
            <connector name="ajp" protocol="AJP/1.3" scheme="http" socket-binding="ajp"/>
            <virtual-server name="default-host" enable-welcome-root="false" default-web-module="bar">
                <alias name="localhost"/>
                <alias name="www.bar.net"/>
            </virtual-server>
            <virtual-server name="foo" enable-welcome-root="false" default-web-module="foo">
                <alias name="www.foo.com"/>
            </virtual-server>
        </subsystem>

      

Both apps have jboss-web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
    <security-domain>java:/jaas/foo</security-domain>
    <context-root>/</context-root>
</jboss-web>

      

Expanding the results of foo.war to:

INSTALLATION: Failed to process the INSTALL phase of deployment "foo.war"

Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.web.deployment.default.host./.realm is already registered

What's the correct configuration? Where is the mistake?

+3


source to share


3 answers


That was enough to add foo to my config, now works well with mod_jk. I wrote about this: http://fabiobozzo.wordpress.com/2013/02/25/multiple-web-applications-with-jboss-and-apache/



0


source


I think the problem is that you have defined the same context root for two applications. You cannot have two applications with the same context root in Sametime. One possible solution would be to define a different context for each application (/ foo and / bar, respectively) and use the ProxyPass directive on each Apache virtual host.

<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>

      

Thus, you can access your applications directly through the addresses: www.bar.com and www.foo.com, respectively. (Note, if you have Apache acting as a proxy and using its own virtual hosts, there is no need to define a JBoss virtual host).



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

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

      

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

+2


source


in fact, how good he was. no need to use a proxy if he doesn't want to. The missing piece of the original config is that it never mentioned this jboss-web.xml alias.

<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 application

<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 tag in the web module. you create a paradox with this mess. you either go to one or the other, or to the other. that is, when you don't have a mapped alias.

0


source







All Articles