...
Now you need to define those virtual hosts in Geronimo's config.xml
so it can recognize them. This section provides two different virtual hosts definitions, that is creating two new HostGBean (TomcatVirtualHost1 and TomcatVirtualHost2) in the Geronimo configuration, one of those will have multiple host names aliases. The goal of this example is to have standard predeployed applications listening by default on all the available host names. Then to have an application listening on a single virtual host ( this will be virtualhost1.com ) and another application listening on a different virtual host ( this will be virtualhost2.com ) with two additional aliases ( this will be virtualhost3.com and virtualhost4.com ).
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?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>virtualhost1<host>virtualhost2.com</host> </web-app> |
Save the changed to the geronimo-web.xml
file and generate a second WAR file by typing the following command from the <app_home> directory:
...
No Format bgColor #000000 borderStyle solid
D:\geronimo-1.1\bin>java -jar deployer.jar --user system --password manager deploy \000-VH-sample\HelloWorld-VH\HelloWorld_2.war
Deployed sample.applications/HelloWorldApp_2/1.1/war @
http://hc2t60p:8080/hello_2
So, with With the applications deployed the only thing left is to test them. Test hello_1 first, try to access the hosts names defined on the Geronimo server machine:
Host name / Virtual Host | Status Access |
---|---|
http://hc2t60p:8080/hello_1 | Fail |
http://localhost:8080/hello_1 | Fail |
http://virtualhost1.com:8080/hello_1 | SUCCESS!!! |
http://virtualhost2.com:8080/hello_1 | Fail |
http://virtualhost3.com:8080/hello_1 | Fail |
http://virtualhost4.com:8080/hello_1 | Fail |
Now repeat the tests for hello_2.
Host name / Virtual Host | Access |
---|---|
http://hc2t60p:8080/hello_2 | Fail |
http://localhost:8080/hello_2 | Fail |
http://virtualhost1.com:8080/hello_2 | Fail |
http://virtualhost2.com:8080/hello_2 | SUCCESS!!! |
http://virtualhost3.com:8080/hello_2 | SUCCESS!!! |
http://virtualhost4.com:8080/hello_2 | SUCCESS!!! |
Congratulations!!! you have successfully configured and deployed two applications to two different virtual hosts and aliases.