Application normally runs on Tomcat embedded in Spring Boot and does not run on Tomcat on my Server

Asked

Viewed 256 times

-1

good afternoon. I’m having a problem with an application using Spring Boot 2. Basically it is a Restapi with some "scheduled methods".

In the Spring Boot embedded Tomcat it works normally, runs the scheduled methods and responds to HTTP requests.

I made the "War" Deploy on my production Tomcat server, the status of the application is "Running", but when I make an HTTP request the context is not found and I get error 404. I also noticed that on the Spring Boot embedded server the logs I put using the LOGGER class so that I could follow when a scheduled method was executed are displayed normally, already in my production Tomcat these logs do not appear.

Someone came across something similar?

Below the POM file of my application

enter the code here http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.springframework.boot spring-boot-Starter-Parent 2.2.0.BUILD-SNAPSHOT ####integracaMega integral 0.0.1-SNAPSHOT War integral Service for integration between Mega and RM

<properties>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc8</artifactId>
        <version>12.1.0.2</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>

    </plugins>
</build>

<repositories>
    <repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
    </pluginRepository>
</pluginRepositories>

1 answer

0


To run on external Tomcat you have to do two things:

1 - Include dependency in your pom.xml - Already done in your case

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-tomcat</artifactId>
   <scope>provided</scope>
</dependency>

2 - Change application class to inherit from SpringBootServletInitializer

@SpringBootApplication
public class SpringBootTomcatApplication extends SpringBootServletInitializer {

} 

When I needed to run my application on an external Tomcat I changed these two items and everything went perfect.

  • rnd_rss, thanks for the return, the dependency was already in the POM archive, but had forgotten to extend to Springbootservletinitializer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.