[英]Spring application working in eclipse but same not working when deployed on tomcat 8
I am using maven, eclipse. 我正在使用Maven,Eclipse。 Everything is fine when running from eclipse. 从Eclipse运行时一切正常。 But same if I deploy on tomcat it returns http status 404. log says No Spring WebApplicationInitializer types detected on classpath but I am using web.xml 但是同样,如果我在tomcat上部署,它将返回http状态404。日志显示在类路径上未检测到Spring WebApplicationInitializer类型,但我使用的是web.xml
I am not able to figure out issue here, if anybody can help please. 如果有人可以帮助,我在这里无法解决问题。 There is no issue with filter and servlet mapping. 过滤器和servlet映射没有问题。
web.xml web.xml
contextClass org.springframework.web.context.support.AnnotationConfigWebApplicationContext contextClass org.springframework.web.context.support.AnnotationConfigWebApplicationContext
<!-- Location of Java @Configuration classes that configure the components
that makeup this application -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>com.asuare.temapp</param-value>
</context-param>
<context-param>
<param-name>org.atmosphere.cpr.sessionSupport</param-name>
<param-value>true</param-value>
</context-param>
<!-- Specifies the default mode of this application, to be activated if
no other profile (or mode) is specified -->
<context-param>
<param-name>spring.profiles.default</param-name>
<param-value>mysql</param-value>
</context-param>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Secures the application -->
securityFilter org.springframework.web.filter.DelegatingFilterProxy targetBeanName springSecurityFilterChain true securityFilter org.springframework.web.filter.DelegatingFilterProxy targetBeanName springSecurityFilterChain true
<filter-mapping>
<filter-name>securityFilter</filter-name>
<url-pattern>/*</url-pattern>
<async-supported>true</async-supported>
</filter-mapping>
<!-- Handles requests into the application -->
<servlet>
<servlet-name>temapp</servlet-name>
<servlet-class>org.atmosphere.cpr.MeteorServlet</servlet-class>
<async-supported>true</async-supported>
<init-param>
<param-name>org.atmosphere.servlet</param-name>
<param-value>org.springframework.web.servlet.DispatcherServlet</param-value>
</init-param>
<!-- No explicit configuration file reference here: everything is configured
in the root container for simplicity -->
<init-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext
</param-value>
</init-param>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>temapp</servlet-name>
<url-pattern>/</url-pattern>
<async-supported>true</async-supported>
</servlet-mapping>
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>
com.opensymphony.module.sitemesh.filter.PageFilter
</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<async-supported>true</async-supported>
</filter-mapping>
<error-page>
<error-code>403</error-code>
<location>/denied</location>
</error-page>
<error-page>
<error-code>401</error-code>
<location>/restapi/denied</location>
</error-page>
server log: 服务器日志:
24-Jul-2016 13:20:57.816 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath 24-Jul-2016 13:20:58.331 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log Initializing Spring root WebApplicationContext 24-Jul-2016 13:21:25.913 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log Initializing Spring FrameworkServlet 'sportingEasy' 24-Jul-2016 13:21:42.699 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath 24-Jul-2016 13:22:02.971 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath 24-Jul-2016 13:22:03.034 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized() 24-Jul-2016 13:22:03.034 INFO [localhost-startStop-1] org.a 2016年7月24日13:20:57.816 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log在类路径上未检测到Spring WebApplicationInitializer类型24-Jul-2016 13:20:58.331 INFO [localhost- startStop-1] org.apache.catalina.core.ApplicationContext.log初始化Spring根WebApplicationContext 2016年7月24日13:21:25.913 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log初始化Spring FrameworkServlet'sportingEasy'2016年7月24日13:21:42.699信息[localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log在类路径上未检测到Spring WebApplicationInitializer类型2016年7月24日13:22:02.971 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log在类路径上未检测到Spring WebApplicationInitializer类型2016年7月24日13:22:03.034 INFO [localhost-startStop-1] org.apache.catalina。 core.ApplicationContext.log ContextListener:contextInitialized()2016年7月24日13:22:03.034 INFO [localhost-startStop-1] org.a pache.catalina.core.ApplicationContext.log SessionListener: contextInitialized() 24-Jul-2016 13:22:48.611 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath pache.catalina.core.ApplicationContext.log SessionListener:contextInitialized()2016年7月24日13:22:48.611 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log在类路径上未检测到Spring WebApplicationInitializer类型
I also had the same problem. 我也有同样的问题。 My maven had tomcat7 plugin but the JRE environment was 1.6. 我的maven有tomcat7插件,但JRE环境是1.6。 I changed my tomcat7 to tomcat6 and the error was gone.Could you check once your JRE environment and try. 我将tomcat7更改为tomcat6,错误消失了。您能否检查一下JRE环境并尝试一下。 Also please add the 'maven-war-plugin' version 2.6 in your pom.xml 另外,请在pom.xml中添加“ maven-war-plugin” 2.6版
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.