How to deploy war file in root(/) context to Wildfly ver 9.0.1

后端 未结 6 728
無奈伤痛
無奈伤痛 2021-02-07 10:49

I am newbie for Wildfly till now I was working on tomcat to deploy my applications. Now just for add on features of Wildfly we want to move on to this. I am using Windows Os, I

相关标签:
6条回答
  • 2021-02-07 11:05

    If your web module is inside an ear you can you the following syntax

    <host name="default-host" alias="localhost" default-web-module="myApp.ear.myWebApp.war">
    
    0 讨论(0)
  • 2021-02-07 11:11

    If you are using Maven to deploy your application, you can change the default war file name in your pom.xml to ROOT like this:

    ...
    </dependencies>
    <build>
        <!-- <finalName>${project.artifactId}</finalName> -->
        <finalName>ROOT</finalName>
    

    When you deploy your application using Maven, Wildfly will automatically host it under /. This way, you prevent changing the name of the war file yourself.

    0 讨论(0)
  • 2021-02-07 11:18

    For my wildfly 9.0.1 deployment, we did the following two and it worked.

    1. jboss-web.xml as described above by other experts.

    2. In standalone.xml,

      <host name="default-host" alias="localhost, myAppDomain.com" default-web-module="myApp.war">
          <location name="/" handler="welcome-content"/>
          <filter-ref name="server-header"/>
          <filter-ref name="x-powered-by-header"/>
      </host>
      
    0 讨论(0)
  • 2021-02-07 11:19

    Two files have to be added in WEB-INF folder before creating a war file

    1. jboss-web.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="
              http://www.jboss.com/xml/ns/javaee
              http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd">
          <context-root>/</context-root>
      </jboss-web>
      
    2. empty bean.xml

    0 讨论(0)
  • 2021-02-07 11:19

    The welcome page has a note at the bottom,

    To replace this page set "enable-welcome-root" to false in your server configuration and deploy your own war with / as its context path.

    Please confirm if you did set the enable-welcome-root to false.

    0 讨论(0)
  • 2021-02-07 11:25

    To override the welcome webapp with Wildfly, you need to create a jboss-web.xml in the WEB-INF of your webapp with this content:

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

    But if you try to access to the root directory (e.g. http://localhost:8080/) you will still have the default welcome content. To remove it, you just need to rename the directory welcome-content in the Wildfly directory.

    0 讨论(0)
提交回复
热议问题