0

I am new in Spring Boot and I am trying to use it in my project which is configured with servlet 2.5. When I run it with Eclipse Maven Plugin with the goal "spring-boot:run" the execution returns the following error:

`[Tomcat-startStop-1] ERROR o.apache.catalina.core.ContainerBase - A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]
at java.util.concurrent.FutureTask.report(FutureTask.java:122) [na:1.8.0_60]
at java.util.concurrent.FutureTask.get(FutureTask.java:192) [na:1.8.0_60]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:939) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419) [tomcat-embed-core-8.5.11.jar:8.5.11]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409) [tomcat-embed-core-8.5.11.jar:8.5.11]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_60]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_60]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_60]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_60]

My project has a parent and 3 modules, one of that childs is the web project.

My configuration is the following:

  • In the parent pom:

    <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.2.RELEASE</version> </parent> ... <properties> <springBoot.version>1.5.2.RELEASE</springBoot.version> </properties> ...

    </dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>${springBoot.version}</version> </dependency>
    <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId>
    <version>${springBoot.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-legacy</artifactId> <version>1.1.0.RELEASE</version> </dependency> </dependencies> </dependencyManagement>

-In the web child pom:

`   <dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-legacy</artifactId>
    </dependency>
</dependencies>
`
...
`
<plugins>
   <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
   </plugin>
</plugins>
`   
  • In the web.xml: <listener>
    <listener-class>org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener</listener-class> </listener>
Mark McLaren
  • 11,470
  • 2
  • 48
  • 79

1 Answers1

0

spring-boot-legacy, 1.1.0.RELEASE is only guaranteed to work with Spring Boot, 1.4.2.RELEASE.

Not everything that works in the usual Spring Boot will work. Programatically defined servlet filters and servlets (e.g. using FilterRegistrationBean or ServletRegistrationBean) will not work, I think this is due to limitations in Servlet 2.5. Obviously Servlet 3.0 annotations will not work either (e.g. @WebServlet)

Tomcat 6 supports Servlet 2.5. So a Spring Boot legacy app should work fine using something like:

mvn tomcat6:run

<plugin>
  <artifactId>tomcat6-maven-plugin</artifactId>
  <groupId>org.apache.tomcat.maven</groupId>
  <version>2.0</version>
</plugin>

Also it is important that you give the SpringBootContextLoaderListener some clue as to where to find your "Application" class (the class containing @SpringBootApplication), e.g.:

Your web.xml will contain something like:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>demo.Application</param-value>
</context-param>

Once you understand the limitations, it is amazing what does work!

Mark McLaren
  • 11,470
  • 2
  • 48
  • 79