raghera
raghera

Reputation: 633

Deploying Spring Boot App in Wildfly 9.0.2

I want to deploy a simple Spring Boot Rest app into a Wildfly 9.0.2 server. It seems to deploy but can't access any of the services.

I have been following various instructions such as: https://docs.spring.io/spring-boot/docs/current/reference/html/howto-traditional-deployment.html

but still doesn't seem to work for me.

This is my pom.xml file

<?xml version="1.0" encoding="UTF-8"?>

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0

<groupId>com.vodafone.er</groupId>
<artifactId>config-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<name>config-app</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.6.RELEASE</version>
    <relativePath/>
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    <start-class>com.vodafone.er.configapp.ConfigAppApplication</start-class>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-classic</artifactId>
            </exclusion>
        </exclusions>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.module</groupId>
        <artifactId>jackson-module-parameter-names</artifactId>
        <version>2.8.7</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.datatype</groupId>
        <artifactId>jackson-datatype-jdk8</artifactId>
        <version>2.8.7</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.datatype</groupId>
        <artifactId>jackson-datatype-jsr310</artifactId>
        <version>2.8.7</version>
    </dependency>
</dependencies>

<!--<build>-->
    <!--<plugins>-->
        <!--<plugin>-->
            <!--<groupId>org.springframework.boot</groupId>-->
            <!--<artifactId>spring-boot-maven-plugin</artifactId>-->
            <!--<configuration>-->
                <!--<jvmArguments>-->
                    <!-- -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005-->
                <!--</jvmArguments>-->
            <!--</configuration>-->
        <!--</plugin>-->
    <!--</plugins>-->
<!--</build>-->

And here is my application / controller class:

@SpringBootApplication
@ComponentScan
@EnableAutoConfiguration
public class ConfigAppApplication extends     
    SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication.run(ConfigAppApplication.class, args);
    }

    @Override
        protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
            return application.sources(ConfigAppApplication.class);
        }
    }

    @RestController
    class ConfigController {

    @RequestMapping("/hello")
    public String hello() {
        return "hello world";
    }
}

I deploy it on the $JBOSS_HOME/standalone/deployments and it tells me it is deployed.

15:51:12,008 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0016: Replaced deployment "config-app-0.0.1-SNAPSHOT.war" with deployment "config-app-0.0.1-SNAPSHOT.war"

and I get the marker file:

config-app-0.0.1-SNAPSHOT.war.deployed

The jmx console tells me the application is enabled too. Whenever I try and access the endpoint e.g. when I try and access the root-context I get a 403 forbidden, but when I try and access the rest resource e.g. localhost:8080/config-app/hello I get a 404 error.

Any ideas what I am doing wrong?

Thanks

Upvotes: 0

Views: 2863

Answers (2)

Ramzi Guetiti
Ramzi Guetiti

Reputation: 132

<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>

Upvotes: 0

K.Nicholas
K.Nicholas

Reputation: 11551

Wildfly uses undertow servlet container. Try adding support for that in your application.

Ref: 73.13 Use Undertow instead of Tomcat

<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>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-undertow</artifactId>
</dependency>

Upvotes: 4

Related Questions