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
  • Configuring Virtual Host in Jetty

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

Anchortoptop

...

In the Configuring Virtual Host in Tomcat section we describe how to define a Virtual Host in the Geronimo's config.xml so applications can be deployed to specific hosts ( Virtual Hosts) with a minimal configuration on the application deployment plans side. The need to define Virtual Hosts at the server level ( config.xml ) only applies to Geronimo with Tomcat distributions.

excerptINLINE

For the Jetty distribution of Apache Geronimo this configuration is dramatically simpler.

...

In this example we continue to use the HelloWorld Web sample application covered in the Quick start - Apache Geronimo for the impatient section. Here is a summary of steps

  1. Create a app_home directory somewhere in the file system, from now on we will reference this location as <app_home>.
  2. Create a HelloWorld.jsp file in the <app_home> directory and paste the following content. Code BlockXMLXMLtitleHelloWorld.jsp <html> <head> <jsp:useBean id="datetime" class="java.util.Date"/> <title>Basic HelloWorld JSP</title> </head> <body bgcolor="#909DB8"> <h1><font face="tahoma" color="white">Hello world from GERONIMO!</font></h1> <font face="tahoma" color="white">on ${datetime}</font> </body> </html>
  3. Create a WEB-INF directory under <app_home>.
  4. Create a web.xml file in the <app_home>\WEB-INF directory and paste the following content. Code BlockXMLXMLtitleweb.xml <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <welcome-file-list> <welcome-file>HelloWorld.jsp</welcome-file> </welcome-file-list> </web-app>
  5. Create a geronimo-web.xml file in the <app_home>\WEB-INF directory and paste the following content. Code BlockXMLXMLtitlegeronimo-web.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</artifactId> <version>2.1</version> <type>war</type> </moduleId> </environment> <context-root>/hello</context-root> <!-- Add this line to define a new Virtual Host in Geronimo - Jetty --> <virtual-host>virtualhost1.com</virtual-host> </web-app>

If you compare this deployment plan with the one described in the Quick start - Apache Geronimo for the impatient section you will note that only one line has been added, that is <virtual-host>virtualhost1.com</virtual-host>. This is all you need to define a virtual host in Geronimo with Jetty.

...

<geronimo_home>\bin\deploy --user system --password manager deploy --inPlace <app_home>

No FormatbgColor#000000borderStylesolid D:\geronimo-jetty6-jee5-2.1\bin>deploy --user system --password manager deploy --inPlace \HelloWorld_2.1 Using GERONIMO_BASE: D:\geronimo-jetty6-jee5-2.1 Using GERONIMO_HOME: D:\geronimo-jetty6-jee5-2.1 Using GERONIMO_TMPDIR: D:\geronimo-jetty6-jee5-2.1\var\temp Using JRE_HOME: C:\Java\jdk1.5.0_06\\jre Deployed sample.applications/HelloWorldApp/2.1/war @ http://hcunico:8080/hello

Note that even when the successful deployment message on screen shows that the application has been deployed to the http://XYZ:8080/hello host, the application will only be accessible via the virtual host previously defined in the <virtual-host> tag on the geronimo-web.xml deployment plan.