Issue
I'm trying to deploy a second web application to a Wildfly server currently hosting a single application. I've made the following modifications to standalone.xml (see href="https://stackoverflow.com/questions/37032769/accessing-multiple-web-applications-on-jboss7-or-wildfly">Accessing Multiple web applications on Jboss7 or Wildfly - my need is essentially the same):
Under <subsystem xlmns="urn:jboss:domain:undertow:8.0>, added
<server name="dispatch-server">
<http-listener name="default" socket-binding="dispatch"/>
<host name="dispatch-host" default-web-module="Dispatch.war" alias="Dispatch.com">
</host>
</server>
Next, under <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">, added
<socket-binding name="dispatch" port="${jboss.https.port:8081}"/>
Finally, under <Deployments>, added
<deployment name="Dispatch.war" runtime-name="Dispatch.war">
<fs-archive path="${jboss.home.dir}/standalone/deployments/Dispatch.war" />
</deployment>
web.xml content for the deployed Dispatch.war:
<servlet>
<servlet-name>DispatchServlet</servlet-name>
<servlet-class>blah.blah.blah.DispatchServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DispatchServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
I wrote a little application to test connecting to the servlet, using "http://localhost:8081", but I get an HTTP 404 error. I've tried additionally with "http://localhost:8081/DispatchServlet" with no changes.
I found other tutorials mentioning the need for a jboss-web.xml file bundled with Dispatch.war, so I added a barebones one that looks like:
<jboss-web>
<context-root>/</context-root>
</jboss-web>
It didn't impact the behavior I was seeing. I also tried changing the context-root to "DispatchServlet" and then hitting "http://localhost:8081/DispatchServlet" with nothing.
Is there something obvious I'm goofing on?
Solution
I think you are over complicating the issue. If you want to deploy multiple web apps, just drop ear war within the deployments directory. When they deploy the log shows their context path, then access any content relative to that path, e.g
/war1/DispatchServlet /war2/DispatchServlet
If using different paths is not acceptable, then in order to do as you are trying, you need to follow the guides that explain how to use ROOT.war files and the associated changes to standalone-full.xml to disable the inbuilt default
Answered By - Will T
Answer Checked By - David Goodson (JavaFixing Volunteer)