HomeDocumentation > Reference > Samples > Sample applications > app-per-port - Running multiple web apps on different ports

Running web apps on different ports

There are several situations in which you may need to expose different web apps on different ports on the same server, for instance you might want an admin or monitoring application to be on a different port than production apps. For both Jetty and Tomcat in order to do this you need to set up an additional web container (or server) for each port or set of ports. This sample includes a couple simple wars and an ear containing them. It includes a simple jetty demo of simply exposing a war on a new port, with the web container configuration right in the web app plan, and a demo for both jetty and tomcat showing how to assure that the new ports are opened only after the web apps they serve are completely deployed and in service, thus preventing any 404 errors.


The sample consists of two sample web apps and an ear containing them both and a third dummy web app whose plan will contain the connector gbeans. The third should be listed last in appliction.xml to assure it is started after the other two.

Single War configuration

The app-per-port-war1-jetty plugin includes a plan for the app-per-port-war1 webapp that sets the context root, indicates which web container to use for the web app, and includes the 3 gbeans needed for the web app: JettyWebContainer, a http nio connector, and an NCSA log.

Ear configuration.

In order to expose an app on a particular port in jetty or tomcat it is necessary to set up an entire web server, not just the required connector. The engine and related gbeans for this are in the top level ("ear") of the geronimo plan.

Web module configuration.

The geronimo plans for the web modules include the following element to specify which web container the web module is to be deployed to.



The separate web apps can be accessed at