WebSphere CE – Deploy WAR on its own port
I was tasked by the powers that be to figure out how to deploy a WAR in WebSphere Application Server Community Edition (WSASCE) under a separate port from other applications that were already running on our test server. After much googling and frustration, since I have never worked with WSASCE before, I finally figured it out.
This ended up being fairly simple, however the the example from the WebSphere docs did not work for me. I then was able to finally find some Geronimo docs that ended up working for me after a few minor adjustments since the example was for deploying an EAR.
Essentially all that needs to be done is to instruct WSASCE to create a new web container to deploy your WAR to. This can all be done via the deployment plan for your WAR.
Here is a sample deployment plan. Please note that there are a few things you will need to tweak for your envirnoment, which are noted after the sample.
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-2.0.1">
<environment>
<moduleId>
<groupId>GROUP_ID</groupId>
<artifactId>ARTIFACT_ID</artifactId>
<version>VERSION</version>
<type>war</type>
</moduleId>
<dependencies />
<hidden-classes />
<non-overridable-classes />
</environment>
<context-root>/YOUR_CONTEXT</context-root>
<web-container>
<gbean-link>TomcatWebContainer1</gbean-link>
</web-container>
<gbean name="TomcatWebConnector1">
<attribute name="name">HTTP</attribute>
<attribute name="host">0.0.0.0</attribute>
<attribute name="port">8090</attribute>
<attribute name="maxHttpHeaderSize">8192</attribute>
<attribute name="maxThreads">150</attribute>
<attribute name="minSpareThreads">25</attribute>
<attribute name="maxSpareThreads">75</attribute>
<attribute name="enableLookups">false</attribute>
<attribute name="redirectPort">8453</attribute>
<attribute name="acceptCount">100</attribute>
<attribute name="connectionTimeout">20000</attribute>
<attribute name="disableUploadTimeout">true</attribute>
<reference name="TomcatContainer">
<name>TomcatWebContainer1</name>
</reference>
<reference name="ServerInfo">
<name>ServerInfo</name>
</reference>
</gbean>
<gbean name="TomcatWebContainer1">
<attribute name="catalinaHome">var/catalina</attribute>
<reference name="EngineGBean">
<name>TomcatEngine1</name>
</reference>
<reference name="ServerInfo">
<name>ServerInfo</name>
</reference>
<reference name="WebManager">
<name>TomcatWebManager</name>
</reference>
</gbean>
<gbean name="TomcatEngine1">
<attribute name="className">org.apache.geronimo.tomcat.TomcatEngine</attribute>
<attribute name="initParams">
name=Geronimo1
</attribute>
<reference name="DefaultHost">
<name>TomcatHost1</name>
</reference>
<references name="Hosts">
<pattern>
<name>TomcatHost1</name>
</pattern>
</references>
<reference name="RealmGBean">
<name>NoSecurityRealm</name>
</reference>
</gbean>
<gbean name="TomcatHost1">
<attribute name="className">org.apache.catalina.core.StandardHost</attribute>
<attribute name="initParams">
name=localhost1
appBase=
workDir=work1
</attribute>
</gbean>
<gbean name="NoSecurityRealm">
<attribute name="className">org.apache.geronimo.tomcat.realm.TomcatEJBWSGeronimoRealm</attribute>
</gbean>
</web-app>
You will need to replace the following placeholders in the above XML with values for your own WAR.
- GROUP_ID – Your group ID
- ARTIFACT_ID – Your artifact ID
- VERSION – The version of your WAR
- YOUR_CONTEXT – The root context for your WAR
You may also modify the following for your own environment if desired
- TomcatWebContainer1 is the name of the new web container.
- TomcatEngine1 is the name of the new engine for the new web container.
- TomcatHost1 is the name of the new virtual host in the new web container.
- TomcatWebManager is the name of the web manager of the new web container.
- TomcatWebManager is the name of the web manager defined in the initial server.
- TomcatJAASRealm is the name of the Tomcat realm for authenticating and authorizing users.
- TomcatJAASRealm is the name of the realm defined in the initial server configuration.
- 0.0.0.0 is replaced with the host name or IP address of the web containers host. The value localhost will restrict access to requesters in the server’s host. Use the value 0.0.0.0 if you don’t want to provide the specific IP Address or host name.
- 8090 is replaced with the port number where the HTTP connector will listen for requests.
To deploy your WAR into the new web container, include the <web-container> element and specify a <gbean-link> to the new container where TomcatWebContainer1 is replaced with the name of the container GBean.
... <web-container> <gbean-link>TomcatWebContainer1</gbean-link> </web-container> ...
Now just deploy your WAR with your new handy-dandy deployment plan.