'Springboot 202 with Apache Tomcat (TomEE)/8.5.6 (7.0.2)

I am trying to deploy Springboot 202 application on Apache Tomcat (TomEE)/8.5.6 (7.0.2).

During deployment of generated war file(customotmmportal.war), I dont see any error when tomee starts but tomee hangs after printing these lines.

Error:

localhost-startStop-1 2022-05-06T13:40:09,322 | INFO | session=402906812 | user=customuser | com.server.scheduler.task.UpdateScheduledJobTask | Updated scheduled job with name:Asset Expire Events localhost-startStop-1 2022-05-06T13:40:09,343 | INFO | session=402906812 | user=customuser | com.server.security.session.task.LogoutTask | User customuser (session 402906812) has logged out localhost-startStop-1 2022-05-06T13:40:09,435 | INFO | session= | user= | OpenEJB.tomcat | ------------------------- localhost -> /customotmmportal localhost-startStop-1 2022-05-06T13:40:09,915 | INFO | session= | user= | org.apache.jasper.servlet.TldScanner | At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.

localhost-startStop-1 2022-05-06T13:40:09,942 | INFO | session= | user= | org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/customotmmportal] | 1 Spring WebApplicationInitializers detected on classpath

**Code1:**

@RestController
@EnableAutoConfiguration
public class MessageController {

    @GetMapping("/hello")
    public String hello() {
        return "Hello World";
    }

}

**code 2:**
@SpringBootApplication
public class SpringBootApp extends SpringBootServletInitializer{
  
 @Override
  protected SpringApplicationBuilder configure(
    SpringApplicationBuilder builder) {
      return builder.sources(SpringBootApp.class);
  }

  public static void main(String[] args) {
      SpringApplication sa = new SpringApplication(
              SpringBootApp.class);
      sa.run(args);
  }
  
}

**pom.xml:**
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.2.RELEASE</version>
  </parent>
 

 
  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      <exclusions>
            <exclusion>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                    <groupId>org.springframework.boot</groupId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
                
                
                
            </exclusions>
    </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-hateoas</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
    </dependency>
  </dependencies>
 
  <build>
    <finalName>customotmmportal</finalName>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </execution>
                </executions>
      </plugin>
    </plugins>
  </build>


Solution 1:[1]

Try to add the mainclass and package to war in your pom.xml file as

<start-class>com.example.YourMainClass</start-class>

And

<packaging>war</packaging>

and on your main Method change to

SpringApplication.run(SpringBootApp.class,args);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Carron Muleya