Search code examples
javaspringspring-boottomcatapache-tomee

Spring Boot application not running on TomEE Plus


I have a spring boot application that I am trying to deploy onto a TomEE Plus server. The application works perfectly fine with the embedded Tomcat server and on a Tomcat 9.0.43 setup. I copy the deployment files into the TomEE webapps folder, start the server and ... nothing.

I don't see the usual Spring Boot startup logo and TOMEE seems to just skip the spring boot application. Instead, I get a the following errors (shortened for clarity):

java.lang.IllegalStateException: Error starting child
     at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:720)
     at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
     at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:706)
     at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1133)
...
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/MyApp]]
     at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
     at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:717)
     ... 37 more
Caused by: java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/TryCatchFinally
     at java.lang.ClassLoader.defineClass1(Native Method)
     at java.lang.ClassLoader.defineClass(Unknown Source)
     at java.security.SecureClassLoader.defineClass(Unknown Source)
...
Caused by: java.lang.ClassNotFoundException: javax.servlet.jsp.tagext.TryCatchFinally
     at java.net.URLClassLoader.findClass(Unknown Source)
     at java.lang.ClassLoader.loadClass(Unknown Source)
     at java.lang.ClassLoader.loadClass(Unknown Source)
     ... 73 more

My Tomcat configuration is as follows: Apache Tomcat (TomEE)/9.0.39 (8.0.5) running on Windows 10 with JVM 1.8.0_281-b09 from Oracle


Solution

  • It turns out it wasn't working in Tomcat, It was only working in the embedded server.

    I was missing a configure method in the Servlet Initializer

    @SpringBootApplication
    public class Application extends SpringBootServletInitializer {
    
        public static void main(String[] args) {
            SpringApplication.run(Application.class, args);
        }
    
        @Override
      protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
      }
    }