Search code examples
spring-roo

Run war spring roo 2.0.0 RC1 on wildfly


I'm having trouble running the .war that the spring roo spawns on wildfly 10 Executing in the roo shell the following command in the creation of the project: project setup --topLevelPackage com.example --java 8 --packaging WAR

Added path server.contextPath=/teste

After running: Mvn package

It generates a .war that can execute using Java -jar xxxxx-exec.war

It starts correctly and is accessed by the browser. When I play it in the folder deployments the wildfly does not wheel. I found that I had to remove the tomcat built-in spring boot:

<dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      <exclusions>
            <exclusion>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-tomcat</artifactId>
                  </exclusion>
            </exclusions>
</dependency>

Then add:

<dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <scope>provided</scope>
</dependency>

Then I created a new .war and tried to run in wildfly, but it did not run again, not from error or anything, it says it started, but when I try to access the url, it shows forbidden.

Sorry my english, I'm brazilian and I'm using google translate.


Solution

  • To be able to deploy your Spring Boot application in a Wildfly server you need to extend your @SpringBootApplication .java class from SpringBootServletInitializer and implement the configure method.

    With that simple steps, you will be able to deploy and run your application in tomcat, jboss, wildfly, etc.

    To know more about the changes that you should apply, read http://docs.spring.io/spring-boot/docs/1.5.4.RELEASE/reference/htmlsingle/#howto-create-a-deployable-war-file

    Hope it helps,