Search code examples
javaspringtomcatspring-boottomcat6

Tomcat 6.0.35 and java 8


I'm trying to deploy spring boot application to Tomcat 6.0.35.

I downloaded sample application from www.mkyong.com and build .war application. I moved it to tomcat webapps directory.

I can access tomcat 6 homepage, and manager, and even deploy application, but when I go to http://localhost:8080/demo-0.0.1-SNAPSHOT, I get 404 page.

I'm not getting any errors, see below:

catalina.2014-04-21.log:

   kwi 21, 2017 3:33:55 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
kwi 21, 2017 3:33:55 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
kwi 21, 2017 3:33:55 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 709 ms
kwi 21, 2017 3:33:55 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
kwi 21, 2017 3:33:55 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.35
kwi 21, 2017 3:33:55 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor manager.xml
kwi 21, 2017 3:33:56 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor host-manager.xml
kwi 21, 2017 3:33:56 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive spring-boot-web-thymeleaf-1.0.war
kwi 21, 2017 3:33:56 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive demo-0.0.1-SNAPSHOT.war
kwi 21, 2017 3:33:56 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ROOT
kwi 21, 2017 3:33:56 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory docs
kwi 21, 2017 3:33:56 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory examples
kwi 21, 2017 3:33:56 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
kwi 21, 2017 3:33:56 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
kwi 21, 2017 3:33:56 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/28  config=null
kwi 21, 2017 3:33:56 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1141 ms

catalina.out:

    kwi 21, 2017 3:33:55 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
kwi 21, 2017 3:33:55 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
kwi 21, 2017 3:33:55 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 709 ms
kwi 21, 2017 3:33:55 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
kwi 21, 2017 3:33:55 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.35
kwi 21, 2017 3:33:55 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor manager.xml
kwi 21, 2017 3:33:56 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor host-manager.xml
kwi 21, 2017 3:33:56 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive spring-boot-web-thymeleaf-1.0.war
kwi 21, 2017 3:33:56 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive demo-0.0.1-SNAPSHOT.war
kwi 21, 2017 3:33:56 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ROOT
kwi 21, 2017 3:33:56 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory docs
kwi 21, 2017 3:33:56 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory examples
kwi 21, 2017 3:33:56 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
kwi 21, 2017 3:33:56 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
kwi 21, 2017 3:33:56 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/28  config=null
kwi 21, 2017 3:33:56 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1141 ms

localhost.2017-04-21.log:

  kwi 21, 2017 3:33:56 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
kwi 21, 2017 3:33:56 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()

On tomcat 8 deploy works correctly, but unfortunately I have to use tomcat 6.0.35.

I'm using java 1.8.0_121-b13 oracle.

Have I missed some additional configuration?


Solution

  • I add spring-boot-legacy dependency:

    <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-legacy -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-legacy</artifactId>
                <version>1.1.0.RELEASE</version>
            </dependency>
    

    Then I created web.xml in webapp/WEB-INF/ directory and filled with:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>com.mkyong.SpringBootWebApplication</param-value>
        </context-param>
    
        <listener>
            <listener-class>org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener</listener-class>
        </listener>
    
    
        <servlet>
            <servlet-name>appServlet</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <init-param>
                <param-name>contextAttribute</param-name>
                <param-value>org.springframework.web.context.WebApplicationContext.ROOT</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
    
        <servlet-mapping>
            <servlet-name>appServlet</servlet-name>
            <url-pattern>/</url-pattern>
        </servlet-mapping>
    
    </web-app>
    

    Finally, the catalina.out file in /logs/ :

    INFO: Deploying web application archive spring-boot-web-thymeleaf-1.0.war
    
      .   ____          _            __ _ _
     /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
    ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
     \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
      '  |____| .__|_| |_|_| |_\__, | / / / /
     =========|_|==============|___/=/_/_/_/
     :: Spring Boot ::        (v1.4.2.RELEASE)
    
    2017-04-21 16:45:46.240  INFO 13420 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1492785946240 ms
    2017-04-21 16:45:46.263  INFO 13420 --- [           main] org.apache.catalina.startup.Bootstrap    : Starting Bootstrap v6.0.35 on aleksander-K56CB with PID 13420 (/home/aleksander/apache-tomcat-6.0.35/bin/bootstrap.jar started by aleksander in /home/aleksander/apache-tomcat-6.0.35/bin)
    2017-04-21 16:45:46.267  INFO 13420 --- [           main] org.apache.catalina.startup.Bootstrap    : No active profile set, falling back to default profiles: default
    2017-04-21 16:45:46.778  INFO 13420 --- [           main] onConfigNonEmbeddedWebApplicationContext : Refreshing org.springframework.boot.legacy.context.web.AnnotationConfigNonEmbeddedWebApplicationContext@6a8658ff: startup date [Fri Apr 21 16:45:46 CEST 2017]; root of context hierarchy
    2017-04-21 16:45:49.969  INFO 13420 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.legacy.context.web.AnnotationConfigNonEmbeddedWebApplicationContext@6a8658ff: startup date [Fri Apr 21 16:45:46 CEST 2017]; root of context hierarchy
    2017-04-21 16:45:50.064  INFO 13420 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto public java.lang.String com.mkyong.WelcomeController.welcome(java.util.Map<java.lang.String, java.lang.Object>)
    2017-04-21 16:45:50.070  INFO 13420 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
    2017-04-21 16:45:50.070  INFO 13420 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
    2017-04-21 16:45:50.132  INFO 13420 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
    2017-04-21 16:45:50.132  INFO 13420 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
    2017-04-21 16:45:50.208  INFO 13420 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
    2017-04-21 16:45:51.215  INFO 13420 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
    2017-04-21 16:45:51.244  INFO 13420 --- [           main] org.apache.catalina.startup.Bootstrap    : Started Bootstrap in 6.368 seconds (JVM running for 8.515)
    2017-04-21 16:45:51.274  INFO 13420 --- [           main] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'appServlet': initialization started
    2017-04-21 16:45:51.296  INFO 13420 --- [           main] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'appServlet': initialization completed in 22 ms
    kwi 21, 2017 4:45:51 PM org.apache.catalina.startup.HostConfig deployDirectory
    INFO: Deploying web application directory ROOT
    kwi 21, 2017 4:45:51 PM org.apache.catalina.startup.HostConfig deployDirectory
    INFO: Deploying web application directory docs
    kwi 21, 2017 4:45:51 PM org.apache.catalina.startup.HostConfig deployDirectory
    INFO: Deploying web application directory examples
    kwi 21, 2017 4:45:51 PM org.apache.coyote.http11.Http11Protocol start
    INFO: Starting Coyote HTTP/1.1 on http-8080
    kwi 21, 2017 4:45:51 PM org.apache.jk.common.ChannelSocket init
    INFO: JK: ajp13 listening on /0.0.0.0:8009
    kwi 21, 2017 4:45:51 PM org.apache.jk.server.JkMain start
    INFO: Jk running ID=0 time=1/21  config=null
    kwi 21, 2017 4:45:51 PM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 7930 ms
    

    and browser page: screenshot

    Great!