部署在Tomcat 7.0.57上的Spring Boot 1.2.2应用程序无法启动

时间:2015-07-23 12:34:35

标签: java spring tomcat spring-boot

我写了一个春季启动应用程序。当我把它作为WAR放到本地测试Tomcat 7.0.57(XAMPP)的webapps文件夹中时,它会被部署并立即启动。当我在具有相同Tomcat版本的专用测试服务器上执行相同操作时,服务器会部署应用程序但不启动它。当我尝试通过浏览器访问应用程序时,我得到了404响应。

有人知道什么会妨碍服务器启动应用程序?

catalina.out日志:

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

2 个答案:

答案 0 :(得分:2)

问题是我的Tomcat 7使用的是Java 6。

提示是catalina.out日志的以下行:

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.

我通过在tomcat-7 / bin中创建一个setenv.sh来为这个Tomcat切换Java版本,默认情况下,catalina.sh在启动时读取它来设置环境变量。

setenv.sh:

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

Thx @We是博格和@Patouche

答案 1 :(得分:0)

在您的网络initiliazr类(扩展名为SpringBootServletInitializer的类)中,您覆盖了方法configure(SpringApplicationBuilder application),如下所示:

@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);
    }

}

您可以在此页面找到更多信息:http://docs.spring.io/spring-boot/docs/current/reference/html/howto-traditional-deployment.html