简体   繁体   中英

Spring Boot 1.2.2 application deployed on Tomcat 7.0.57 does not start

I wrote a spring boot app. When I put it as a WAR into the webapps folder of a local test Tomcat 7.0.57 (XAMPP) it gets deployed and starts right away. When I do the same on a dedicated test server with the same Tomcat version the server deploys the application but does not start it. When I try to reach the application via browser I get a 404 in response.

Someone got an idea what could hinder the server from starting the application?

catalina.out Log:

Jul 23, 2015 3:16:12 PM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.30 using APR version 1.3.9.
Jul 23, 2015 3:16:12 PM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
Jul 23, 2015 3:16:12 PM org.apache.catalina.core.AprLifecycleListener initializeSSL
INFO: OpenSSL successfully initialized (OpenSSL 1.0.1e 11 Feb 2013)
Jul 23, 2015 3:16:12 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-apr-5009"]
Jul 23, 2015 3:16:12 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 809 ms
Jul 23, 2015 3:16:12 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jul 23, 2015 3:16:12 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.56
Jul 23, 2015 3:16:12 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /opt/tomcat-7/webapps/testapp.war
Jul 23, 2015 3:16:15 PM org.apache.tomcat.websocket.server.WsSci onStartup
INFO: JSR 356 WebSocket (Java WebSocket 1.0) support is not available when running on Java 6. To suppress this message, run Tomcat on Java 7, remove the WebSocket JARs from $CATALINA_HOME/lib or add the WebSocket JARs to the tomcat.util.scan.DefaultJarScanner.jarsToSkip property in $CATALINA_BASE/conf/catalina.properties. Note that the deprecated Tomcat 7 WebSocket API will be available.
Jul 23, 2015 3:16:15 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive /opt/tomcat-7/webapps/testapp.war has finished in 2,683 ms
Jul 23, 2015 3:16:15 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-5009"]
Jul 23, 2015 3:16:15 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2752 ms

The problem was that my Tomcat 7 was using Java 6.

Hint was the following line of the catalina.out log:

INFO: JSR 356 WebSocket (Java WebSocket 1.0) support is not available when running on Java 6. To suppress this message, run Tomcat on Java 7, remove the WebSocket JARs from $CATALINA_HOME/lib or add the WebSocket JARs to the tomcat.util.scan.DefaultJarScanner.jarsToSkip property in $CATALINA_BASE/conf/catalina.properties. Note that the deprecated Tomcat 7 WebSocket API will be available.

I switched the Java version just for this Tomcat by creating a setenv.sh in tomcat-7/bin which is read by default on startup by catalina.sh to set environment variables.

setenv.sh:

export JAVA_HOME=/usr/java/jdk1.7.0_09

Thx @We are Borg and @Patouche

In your web initiliazr class (the one extending SpringBootServletInitializer ) did you override the method configure(SpringApplicationBuilder application) like the following one :

@SpringBootApplication
public class Application extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(Application.class, args);
    }

}

You will find more information on this page : http://docs.spring.io/spring-boot/docs/current/reference/html/howto-traditional-deployment.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM