Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

To define the first HostGBean TomcatVirtualHost_1 add the following lines right after <module name="org.apache.geronimo.configs/tomcat/1.2/car">.

Code Block
xmlxml
borderStylesolid
titleExcerpt from config.xml
xml
...
<gbean gbeanInfo="org.apache.geronimo.tomcat.HostGBean" name="org.apache.geronimo.configs/tomcat/1.2/car?ServiceModule=org.apache.geronimo.configs/tomcat/1.2/car,j2eeType=Host,name=TomcatVirtualHost_1">
<attribute name="className">org.apache.catalina.core.StandardHost</attribute>
<attribute name="initParams">name=virtualhost1.com
       appBase=
       workDir=work</attribute>
</gbean>
...

To add the second HostGBean TomcatVirtualHost_2 add the following lines right after the first HostGBean. These two HostGBeans have been split so it is easier to identify them. The main difference between these two is the <attribute name="aliases">..,..</attribute> line to define the aliases.

xml
Code Block
xml
borderStylesolid
titleExcerpt from config.xml
xml
...
<gbean gbeanInfo="org.apache.geronimo.tomcat.HostGBean" name="org.apache.geronimo.configs/tomcat/1.2/car?ServiceModule=org.apache.geronimo.configs/tomcat/1.2/car,j2eeType=Host,name=TomcatVirtualHost_2">
<attribute name="className">org.apache.catalina.core.StandardHost</attribute>
<attribute name="initParams">name=virtualhost2.com
       appBase=
       workDir=work</attribute>
       <attribute name="aliases">virtualhost3.com,virtualhost4.com</attribute>
</gbean>
...

...

For additional reference, this is the entire config.xml with the two HostGBean already defined.

xml
Code Block
xml
borderStylesolid
titleconfig.xml
xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- ======================================================== -->
<!-- Warning - This XML file is re-generated by Geronimo when -->
<!-- changes are made to Geronimo's configuration, therefore  -->
<!-- any comments added to this file will be lost.            -->
<!-- Do not edit this file while Geronimo is running.         -->
<!-- ======================================================== -->
<attributes xmlns="http://geronimo.apache.org/xml/ns/attributes-1.1">
    <module name="org.apache.geronimo.configs/rmi-naming/1.2/car">
        <gbean name="RMIRegistry">
            <attribute name="port">1099</attribute>
        </gbean>
        <gbean name="NamingProperties">
            <attribute name="namingProviderUrl">rmi://0.0.0.0:1099</attribute>
        </gbean>
        <gbean name="DownloadedPluginRepos">
            <attribute name="repositoryList">http://geronimo.apache.org/plugins/plugin-repository-list-1.2.txt</attribute>
            <attribute name="userRepositories">[]</attribute>
        </gbean>
    </module>
    <module name="org.apache.geronimo.configs/j2ee-server/1.2/car"/>
    <module name="org.apache.geronimo.configs/transaction/1.2/car"/>
    <module name="org.apache.geronimo.configs/j2ee-security/1.2/car">
        <gbean name="JaasLoginServiceRemotingServer">
            <attribute name="host">0.0.0.0</attribute>
            <attribute name="port">4242</attribute>
        </gbean>
        <gbean name="JMXService">
            <attribute name="protocol">rmi</attribute>
            <attribute name="host">0.0.0.0</attribute>
            <attribute name="port">9999</attribute>
            <attribute name="urlPath">/jndi/rmi://0.0.0.0:1099/JMXConnector</attribute>
        </gbean>
    </module>
    <module name="org.apache.geronimo.configs/axis/1.2/car"/>
    <module name="org.apache.geronimo.configs/openejb/1.2/car">
        <gbean name="EJBNetworkService">
            <attribute name="host">0.0.0.0</attribute>
            <attribute name="port">4201</attribute>
        </gbean>
    </module>
    <module load="false" name="org.apache.geronimo.configs/j2ee-corba-yoko/1.2/car">
        <gbean name="NameServer">
            <attribute name="port">1050</attribute>
            <attribute name="host">localhost</attribute>
        </gbean>
    </module>
    <module load="false" name="org.apache.geronimo.configs/j2ee-corba-sun/1.2/car">
        <gbean name="NameServer">
            <attribute name="port">1050</attribute>
            <attribute name="host">localhost</attribute>
        </gbean>
    </module>
    <module name="org.apache.geronimo.configs/system-database/1.2/car">
        <gbean name="DerbyNetwork">
            <attribute name="host">0.0.0.0</attribute>
            <attribute name="port">1527</attribute>
        </gbean>
    </module>
    <module name="org.apache.geronimo.configs/activemq-broker/1.2/car">
        <gbean name="ActiveMQ.tcp.default">
            <attribute name="host">0.0.0.0</attribute>
            <attribute name="port">61616</attribute>
        </gbean>
    </module>
    <module name="org.apache.geronimo.configs/activemq/1.2/car"/>
    <module name="org.apache.geronimo.configs/tomcat/1.2/car">
    <!-- ================================================= -->
	<!--    First HostGBean TomcatVirtualHost_1 defined    -->
    <!-- ================================================= -->
	    <gbean gbeanInfo="org.apache.geronimo.tomcat.HostGBean" name="org.apache.geronimo.configs/tomcat/1.2/car?ServiceModule=org.apache.geronimo.configs/tomcat/1.2/car,j2eeType=Host,name=TomcatVirtualHost_1">
            <attribute name="className">org.apache.catalina.core.StandardHost</attribute>
            <attribute name="initParams">name=virtualhost1.com
                appBase=
                workDir=work</attribute>
        </gbean>
    <!-- ================================================= -->
	<!--   Second HostGBean TomcatVirtualHost_2 defined    -->
    <!-- ================================================= -->
	    <gbean gbeanInfo="org.apache.geronimo.tomcat.HostGBean" name="org.apache.geronimo.configs/tomcat/1.2/car?ServiceModule=org.apache.geronimo.configs/tomcat/1.2/car,j2eeType=Host,name=TomcatVirtualHost_2">
            <attribute name="className">org.apache.catalina.core.StandardHost</attribute>
            <attribute name="initParams">name=virtualhost2.com
                appBase=
                workDir=work</attribute>
            <attribute name="aliases">virtualhost3.com,virtualhost4.com</attribute>
        </gbean>
        <gbean name="TomcatResources"/>
        <gbean name="TomcatWebConnector">
            <attribute name="host">0.0.0.0</attribute>
            <attribute name="port">8080</attribute>
            <attribute name="redirectPort">8443</attribute>
        </gbean>
        <gbean name="TomcatAJPConnector">
            <attribute name="host">0.0.0.0</attribute>
            <attribute name="port">8009</attribute>
            <attribute name="redirectPort">8443</attribute>
        </gbean>
        <gbean name="TomcatWebSSLConnector">
            <attribute name="host">0.0.0.0</attribute>
            <attribute name="port">8443</attribute>
        </gbean>
        <gbean name="org.apache.geronimo.configs/tomcat/1.2/car?ServiceModule=org.apache.geronimo.configs/tomcat/1.2/car,j2eeType=GBean,name=TomcatWebContainer">
            <attribute name="catalinaHome">var/catalina</attribute>
        </gbean>
    </module>
    <module name="org.apache.geronimo.configs/geronimo-gbean-deployer/1.2/car"/>
    <module name="org.apache.geronimo.configs/j2ee-deployer/1.2/car">
        <gbean name="WebBuilder">
            <attribute name="defaultNamespace">http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-1.2</attribute>
        </gbean>
    </module>
    <module name="org.apache.geronimo.configs/connector-deployer/1.2/car"/>
    <module condition="java.is1_5" name="org.apache.geronimo.configs/persistence-jpa10-deployer/1.2/car"/>
    <module name="org.apache.geronimo.configs/openejb-deployer/1.2/car">
        <gbean name="EJBBuilder">
            <attribute name="listener">?name=TomcatWebContainer</attribute>
            <reference name="ServiceBuilders">
                <pattern>
                    <name>GBeanBuilder</name>
                </pattern>
                <pattern>
                    <name>PersistenceUnitBuilder</name>
                </pattern>
            </reference>
        </gbean>
    </module>
    <module load="false" name="org.apache.geronimo.configs/openejb-corba-deployer/1.2/car"/>
    <module name="org.apache.geronimo.configs/client-deployer/1.2/car"/>
    <module name="org.apache.geronimo.configs/axis-deployer/1.2/car"/>
    <module load="false" name="org.apache.geronimo.configs/javamail/1.2/car">
        <gbean name="SMTPTransport">
            <attribute name="host">localhost</attribute>
            <attribute name="port">25</attribute>
        </gbean>
    </module>
    <module name="org.apache.geronimo.configs/sharedlib/1.2/car">
        <gbean name="SharedLib">
            <attribute name="classesDirs">var/shared/classes</attribute>
            <attribute name="libDirs">var/shared/lib</attribute>
        </gbean>
    </module>
    <module name="org.apache.geronimo.configs/tomcat-deployer/1.2/car"/>
    <module name="org.apache.geronimo.configs/welcome-tomcat/1.2/car"/>
    <module name="org.apache.geronimo.configs/webconsole-tomcat/1.2/car"/>
    <module load="false" name="org.apache.geronimo.configs/uddi-tomcat/1.2/car"/>
    <module name="org.apache.geronimo.configs/remote-deploy-tomcat/1.2/car"/>
    <module name="org.apache.geronimo.configs/hot-deployer/1.2/car"/>
    <module load="false" name="org.apache.geronimo.configs/ca-helper-tomcat/1.2/car"/>
</attributes>

...

Open the geronimo-web.xml file and edit the artifactId and context-root to make this deployment unique. Within the web-app section add the host attribute and specify the Virtual Host you want this application to listen, in this case virtualhost1.com.

xml
Code Block
xml
borderStylesolid
titlegeronimo-web.xml for HelloWorld_1
xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.2">
    <environment>
        <moduleId>
            <groupId>sample.applications</groupId>
            <artifactId>HelloWorldApp_1</artifactId>
            <version>1.2</version>
            <type>war</type>
        </moduleId>		
    </environment>
    <context-root>/hello_1</context-root>
    <host>virtualhost1.com</host>
</web-app>

...

We will now repeat this steps to create a second WAR. Edit once again the geronimo-web.xml file and copy the content form the following example. Note that we are only changing the artifactId, context-root and host.

xml
Code Block
xml
borderStylesolid
titlegeronimo-web.xml for HelloWorld_2
xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.2">
    <environment>
        <moduleId>
            <groupId>sample.applications</groupId>
            <artifactId>HelloWorldApp_2</artifactId>
            <version>1.2</version>
            <type>war</type>
        </moduleId>     
    </environment>
    <context-root>/hello_2</context-root>
    <host>virtualhost2.com</host>
</web-app>

...

Host name / Virtual Host

Access

http://hcunico:8080/hello_1Image Removed

Fail

http://localhost:8080/hello_1Image Removed

Fail

http://virtualhost1.com:8080/hello_1Image Removed

SUCCESS!!!

http://virtualhost2.com:8080/hello_1Image Removed

Fail

http://virtualhost3.com:8080/hello_1Image Removed

Fail

http://virtualhost4.com:8080/hello_1Image Removed

Fail

Now repeat the tests for hello_2.

Host name / Virtual Host

Access

http://hcunico:8080/hello_2Image Removed

Fail

http://localhost:8080/hello_2Image Removed

Fail

http://virtualhost1.com:8080/hello_2Image Removed

Fail

http://virtualhost2.com:8080/hello_2Image Removed

SUCCESS!!!

http://virtualhost3.com:8080/hello_2Image Removed

SUCCESS!!!

http://virtualhost4.com:8080/hello_2Image Removed

SUCCESS!!!

Congratulations!!! you have successfully configured and deployed two applications to two different virtual hosts and aliases.

...