0

Default installation of WildFly has only root context specified - for welcome pages

    <subsystem xmlns="urn:jboss:domain:undertow:1.2" instance-id="main">
        <buffer-cache name="default"/>
        <server name="default-server">
            <http-listener name="default" socket-binding="http"/>
            <host name="default-host" alias="localhost">
                <location name="/" handler="welcome-content"/>
                <filter-ref name="server-header"/>
                <filter-ref name="x-powered-by-header"/>
            </host>
        </server>
        <servlet-container name="default">
            <jsp-config/>
            <websockets/>
        </servlet-container>
        <handlers>
            <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
        </handlers>
        <filters>
            <response-header name="server-header" header-name="Server" header-value="WildFly/8"/>
            <response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
        </filters>
    </subsystem>

I have web app available on /webapp and I'd like it to be available from root.

I'm ok with forwarding so I've set it in welcome content so far.

<META HTTP-EQUIV="Refresh" CONTENT="0; URL=/webapp/"/>

I'm not ok with having web app moved from it's context (e.g. directly to root). Also I'd like to avoid referencing app via file system as it is done now.

It should be possible to replace default file handler to have direct forwarding. Is there ~url handler? Maybe it is possible to specify relative address on location or something else? I'm having troubles finding reference docs for these things.

Edit: you see disturbing stuff after you get it posted

arkonautom
  • 958
  • 18
  • 29

2 Answers2

7

1.If you have EAR, you need to just set context-root for web module to "/" in your application.xml.

<module>
  <web>
     <web-uri>webapp.war</web-uri>
     <context-root>/</context-root>
  </web>
</module>

2.If you have WAR, you need to add jboss-web.xml next to web.xml with content:

<jboss-web>
   <context-root>/</context-root>
</jboss-web>

(EDIT)3.You can set default-web-module attribute for default-host

<subsystem xmlns="urn:jboss:domain:undertow:1.1">
    <server name="default-server" default-host="webapp">
        <host name="default-host" alias="localhost" default-web-module="webapp.war">
        </host>
    </server>
</subsystem>
Qwertovsky
  • 1,086
  • 12
  • 13
  • With "I'm not ok with having web app moved from it's context (e.g. directly to root)" I meant I want to leave it at dedicated context. To switch routing without redeploys or changes to deployed apps. – arkonautom Mar 05 '15 at 08:17
  • Did you try set in undertow subsystem? But it requires restart of server. – Qwertovsky Mar 05 '15 at 09:53
  • After googling about default-web-module (which i didn't knew about) I found http://stackoverflow.com/questions/24451699/wildfly-undertow-maping-subdomain-to-war-file-not-working that solves the question I was going to be asking next. – arkonautom Mar 05 '15 at 21:36
1

If you want to keep the context you've got two ways that I know of. You could deploy a ROOT.war with just a single page that forwards. It doesn't have to be called ROOT.war, but that's the default for the /subsystem=undertow/server=default-server/host=default-host. You can change the default-web-module attribute to whatever though.

The other option which might be wrong, but works is to change the $JBOSS_HOME/welcome-content/index.html page. The first approach is probably safer since it should make upgrading easier.

James R. Perkins
  • 16,800
  • 44
  • 60
  • I mentioned that I have forwarding - that's the line in my index. Moving it to ROOT.war doesn't change the approach much - it ain't "configuration" and is kind of "dirty". – arkonautom Mar 05 '15 at 21:43