2

Is it possible to override the root context specified in WEB-INF/jboss-web.xml at deploy time?

I have this jboss-web.xml

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
    <context-root>my-context</context-root>
</jboss-web>

And I want to be able to deploy the application with different root context in in e.g. /another-context for some of my environments, but keep /my-context in other environments.

assylias
  • 321,522
  • 82
  • 660
  • 783
ivargrimstad
  • 21
  • 2
  • 3
  • Symlinking/renaming war file to ROOT.war overrides context from jboss-web.xml and deployes to root context (/). Do Wildfly have simliar functionality as --contextroot for Glassfish to be able to set other contexts than root? – ivargrimstad Jun 09 '14 at 10:54

3 Answers3

1

You can do this via WildFly Maven Plugin (as part of your CI job) or using the WildFly CLI.

The maven variant would be like the following command:

org.wildfly.plugins:wildfly-maven-plugin:deploy-only
    -Dwildfly.deployment.filename=app.war 
    -Dwildfly.deployment.runtime.name=appcontext.war

The app will be deployed under /appcontext.

Note, you should remove the context-root from your jboss-web.xml otherwise this value will win always.

The CLI variant could look like (documentation):

[dply@as wildfly-8.2.0.Final]$ bin/jboss-cli.sh 
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
[disconnected /] connect
[standalone@localhost:9990 /] deploy /path/to/app.war --runtime-name=appcontext.war
CSchulz
  • 10,882
  • 11
  • 60
  • 114
0

For doing this, you could combine maven profiles (e.g. "my-context" and "another-context") and maven resource filtering as explained here: Maven resource filters

It certainly takes a little bit of time until everything works as expected.

Hubert Schumacher
  • 1,683
  • 1
  • 16
  • 25
-1

if you have a EAR file you need to define it at your application.xml

<module>
  <web>
     <web-uri>webapp.war</web-uri>
     <context-root>/my-context</context-root>
  </web>
</module>
add9
  • 1,503
  • 3
  • 17
  • 31