This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • D. Configurando Hosts Virtuales en Geronimo-Tomcat

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

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

Code Block
xml
borderStylesolid
titleExcerpt from config.xml
borderStylesolid
xml
...
<gbean gbeanInfo="org.apache.geronimo.tomcat.HostGBean" name="geronimo/tomcat/1.1/car?ServiceModule=geronimo/tomcat/1.1/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.

Code Block
xmlborderStylesolid
titleExcerpt from config.xml
borderStylesolid
xml
...
<gbean gbeanInfo="org.apache.geronimo.tomcat.HostGBean" name="geronimo/tomcat/1.1/car?ServiceModule=geronimo/tomcat/1.1/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.

Code Block
xmlborderStylesolid
titleconfig.xml
borderStylesolid
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="geronimo/rmi-naming/1.1/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://people.apache.org/~ammulder/plugin-repository-list-1.1.txt</attribute>
<attribute name="userRepositories">[]</attribute>
</gbean>
</module>
<module name="geronimo/j2ee-server/1.1/car"/>
<module name="geronimo/j2ee-security/1.1/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="geronimo/axis/1.1/car"/>
<module name="geronimo/openejb/1.1/car">
<gbean name="EJBNetworkService">
<attribute name="host">0.0.0.0</attribute>
<attribute name="port">4201</attribute>
</gbean>
</module>
<module load="false" name="geronimo/j2ee-corba/1.1/car">
<gbean name="NameServer">
<attribute name="dbDir">var/cosnaming.db</attribute>
<attribute name="port">1050</attribute>
</gbean>
<gbean name="Server">
<attribute name="args">-ORBInitRef, NameService=corbaloc::localhost:1050/NameService</attribute>
</gbean>
<gbean name="UnprotectedServer">
<attribute name="args">-ORBInitRef, NameService=corbaloc::localhost:1050/NameService</attribute>
</gbean>
</module>
<module name="geronimo/system-database/1.1/car">
<gbean name="DerbyNetwork">
<attribute name="host">0.0.0.0</attribute>
<attribute name="port">1527</attribute>
</gbean>
</module>
<module name="geronimo/activemq-broker/1.1/car">
<gbean name="ActiveMQ.tcp.default">
<attribute name="host">0.0.0.0</attribute>
<attribute name="port">61616</attribute>
</gbean>
</module>
<module name="geronimo/activemq/1.1/car"/>
<module name="geronimo/tomcat/1.1/car">
<!-- =========================================== -->
<!-- First HostGBean TomcatVirtualHost_1 defined -->
<!-- =========================================== -->
<gbean gbeanInfo="org.apache.geronimo.tomcat.HostGBean" name="geronimo/tomcat/1.1/car?ServiceModule=geronimo/tomcat/1.1/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_1 defined -->
<!-- ============================================ -->
<gbean gbeanInfo="org.apache.geronimo.tomcat.HostGBean" name="geronimo/tomcat/1.1/car?ServiceModule=geronimo/tomcat/1.1/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="geronimo/tomcat/1.1/car?ServiceModule=geronimo/tomcat/1.1/car,j2eeType=GBean,name=TomcatWebContainer">
<attribute name="catalinaHome">var/catalina</attribute>
</gbean>
</module>
<module name="geronimo/geronimo-gbean-deployer/1.1/car"/>
<module name="geronimo/j2ee-deployer/1.1/car">
<gbean name="WebBuilder">
<attribute name="defaultNamespace">http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-1.1</attribute>
</gbean>
</module>
<module name="geronimo/openejb-deployer/1.1/car">
<gbean name="EJBBuilder">
<attribute name="listener">?name=TomcatWebContainer</attribute>
</gbean>
</module>
<module name="geronimo/client-deployer/1.1/car"/>
<module name="geronimo/axis-deployer/1.1/car"/>
<module load="false" name="geronimo/javamail/1.1/car">
<gbean name="SMTPTransport">
<attribute name="host">localhost</attribute>
<attribute name="port">25</attribute>
</gbean>
</module>
<module name="geronimo/sharedlib/1.1/car">
<gbean name="SharedLib">
<attribute name="classesDirs">var/shared/classes</attribute>
<attribute name="libDirs">var/shared/lib</attribute>
</gbean>
</module>
<module name="geronimo/tomcat-deployer/1.1/car"/>
<module name="geronimo/welcome-tomcat/1.1/car"/>
<module name="geronimo/webconsole-tomcat/1.1/car"/>
<module load="false" name="geronimo/uddi-tomcat/1.1/car"/>
<module name="geronimo/remote-deploy-tomcat/1.1/car"/>
<module name="geronimo/hot-deployer/1.1/car"/>
<module load="false" name="sample.applications/HelloWorldApp/1.1/war"/>
</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.

Code Block
borderStyle
xmlsolid
titlegeronimo-web.xml for HelloWorld_1
borderStylesolid
xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1">
    <environment>
        <moduleId>
            <groupId>sample.applications</groupId>
            <artifactId>HelloWorldApp_1</artifactId>
            <version>1.1</version>
        </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.

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

...