Websphere 8.5 context root change not applying to war file

user36737 picture user36737 · Jun 29, 2014 · Viewed 19.7k times · Source

I need a little help changing the context root of my war in my Websphere 8.5 appserver. I have a war file called test.war When I deploy it to websphere the context root is /test However I want to change this to be /example

When I looked online I read I need to include WEB-INF/ibm-web-ext.xml within test.war so I added that and enter the following:

<web-ext
    xmlns="http://websphere.ibm.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_0.xsd"
    version="1.0">
  <context-root uri="/example"/>
</web-ext>

When I deploy again the context-root is still /test That file has had no effect. Is there something I am missing?

Answer

Gas picture Gas · Jun 29, 2014

The easiest way after installation, is to open web admin console and change the context-root via:

Applications > Application Types > WebSphere enterprise applications > application_name > Context root for web modules.

You could do it also via wsadmin script.

You can provide context name, during application installation via admin console or you can change file name before installation as default context, when you install war is taken from the file name.

The last option would be to create EAR and define application.xml with web module like this:

<web>
  <web-uri>test.war</web-uri>
  <context-root>example</context-root>
</web>