tomcat应用程序启动但立即销毁

时间:2016-05-22 09:44:48

标签: java spring spring-mvc tomcat7

我已在linux框中部署了我的应用程序。我使用的是简易apache tomcat 7版本。我能够看到我的tomcat context is initialized 但是在初始化之后立即,上下文被破坏了。我没有看到日志文件中发生任何异常。

  

[加载   org.springframework.util.ConcurrentReferenceHashMap $ EntryIterator来自   文件:/var/cache/easy-tomcat7/work/Catalina/web.com/web-1.0.0-BUILD-SNAPSHOT/WEB-INF/lib/spring-core-4.2.1.RELEASE.jar]   DEBUG:org.springframework.web.context.ContextLoader - 发布的root   WebApplicationContext作为具有名称的ServletContext属性   [org.springframework.web.context.WebApplicationContext.ROOT]信息:   org.springframework.web.context.ContextLoader - Root   WebApplicationContext:初始化完成时间为7637 ms INFO:   org.springframework.web.context.support.XmlWebApplicationContext -   关闭Root WebApplicationContext:启动日期[Sun May 22 07:58:10   UTC 2016];上下文层次结构的根DEBUG:   org.springframework.core.env.PropertySourcesPropertyResolver -   正在搜索关键' spring.liveBeansView.mbeanDomain'在   [servletConfigInitParams] DEBUG:   org.springframework.core.env.PropertySourcesPropertyResolver -   正在搜索关键' spring.liveBeansView.mbeanDomain'在   [servletContextInitParams] DEBUG:   org.springframework.core.env.PropertySourcesPropertyResolver - 找到   key' spring.liveBeansView.mbeanDomain'在[servletContextInitParams]中   类型[String]和值' dev' DEBUG:   org.springframework.beans.factory.support.DefaultListableBeanFactory -   返回单例bean的缓存实例' lifecycleProcessor'   DEBUG:   org.springframework.beans.factory.support.DefaultListableBeanFactory -   摧毁单身人士   org.springframework.beans.factory.support.DefaultListableBeanFactory@2b48a930:

这是web.xml文件。

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  <display-name>web</display-name>
  <context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>/WEB-INF/config/log4j.xml</param-value>
  </context-param>
  <context-param>  
    <param-name>spring.profiles.active</param-name>  
    <param-value>dev</param-value>  
</context-param>  
<context-param>  
    <param-name>spring.profiles.default</param-name>  
    <param-value>dev</param-value>  
</context-param>
<context-param>  
    <param-name>spring.liveBeansView.mbeanDomain</param-name>  
    <param-value>dev</param-value>  
</context-param>  
  <listener>
    <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
  </listener>
  <filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/login/auth</url-pattern>
    <dispatcher>FORWARD</dispatcher>
  </filter-mapping>
  <filter>
    <filter-name>hiddenHttpMethodFilter</filter-name>
    <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>hiddenHttpMethodFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
            /WEB-INF/spring/root-context.xml            
            /WEB-INF/spring/appServlet/security-context.xml
        </param-value>
  </context-param>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <servlet>
    <servlet-name>web</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>web</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
</web-app>

根context.xml中

    <beans:beans xmlns="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:jdbc="http://www.springframework.org/schema/jdbc"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
        http://www.springframework.org/schema/jdbc
        http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">        


</beans:beans>

1 个答案:

答案 0 :(得分:0)

您是否在@Configuration类中定义了特定于配置文件的配置,例如

 @Configuration
 public class MyConfig {

   @Configuration
   @Profile(value="dev")
   public static class DevConfiuration {
        @Bean
        ///some bean methods here
   }
 } 

如果没有,请尝试完全删除以下个人资料标签,看看它是否已部署。

  <context-param>  
     <param-name>spring.profiles.active</param-name>  
     <param-value>dev</param-value>  
 </context-param>  
 <context-param>  
     <param-name>spring.profiles.default</param-name>  
     <param-value>dev</param-value>  
 </context-param>
 <context-param>  
     <param-name>spring.liveBeansView.mbeanDomain</param-name>  
     <param-value>dev</param-value>  
 </context-param>