【发布时间】:2016-05-28 07:12:52
【问题描述】:
对不起,如果这是微不足道的事情,但我对此很陌生。
这是我的 pom 依赖项:
这一切都是这样工作的,但如果我取消注释 web.xml 中的 <filter> 部分,我会得到
一个或多个过滤器无法启动。
错误。我尝试用谷歌搜索它,但没有成功。我正在使用 Tomcat 8。我不知道该问题还能说什么,因为我正试图弄清楚我自己。我正在关注来自this 链接的教程(使用 XML 配置)。我尝试了不同的 spring 和 spring 安全版本,但每次战争“爆炸”时都会出现上述错误(当然,应用程序无法访问)
是否更新了我不知道的内容.. 还是我遗漏了其他内容?我将在底部发布完整的错误堆栈。
<properties>
<spring.version>4.2.4.RELEASE</spring.version>
<spring.security.version>4.0.3.RELEASE</spring.security.version>
</properties>
<dependencies>
<!-- spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${spring.security.version}</version>
</dependency>
</dependencies>
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"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>SpringMVCVezba2</display-name>
<!--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-->
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
spring-security.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans = "http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">
<http auto-config="true">
<intercept-url pattern="/" access="permitAll" />
<intercept-url pattern="/home**" access="permitAll" />
<intercept-url pattern="/store**" access="isAuthenticated" />
<form-login login-page="/home/index" authentication-failure-url="/accessdenied" />
<csrf/>
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="user" password="123" authorities="USER"/>
</user-service>
</authentication-provider>
</authentication-manager>
</beans:beans>
错误堆栈:
16-Feb-2016 21:15:34.292 INFO [RMI TCP Connection(2)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
16-Feb-2016 21:15:34.458 INFO [RMI TCP Connection(2)-127.0.0.1] org.springframework.web.context.ContextLoader.initWebApplicationContext Root WebApplicationContext: initialization started
16-Feb-2016 21:15:34.757 INFO [RMI TCP Connection(2)-127.0.0.1] org.springframework.web.context.support.XmlWebApplicationContext.prepareRefresh Refreshing Root WebApplicationContext: startup date [Tue Feb 16 21:15:34 CET 2016]; root of context hierarchy
16-Feb-2016 21:15:34.870 INFO [RMI TCP Connection(2)-127.0.0.1] org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-servlet.xml]
16-Feb-2016 21:15:35.990 INFO [RMI TCP Connection(2)-127.0.0.1] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.register Mapped "{[/home/index || /home/ || /home || /index || /]}" onto public java.lang.String com.nemanjat94.controllers.HomeController.index(org.springframework.ui.Model,com.nemanjat94.models.User)
16-Feb-2016 21:15:36.218 INFO [RMI TCP Connection(2)-127.0.0.1] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.initControllerAdviceCache Looking for @ControllerAdvice: Root WebApplicationContext: startup date [Tue Feb 16 21:15:34 CET 2016]; root of context hierarchy
16-Feb-2016 21:15:36.327 INFO [RMI TCP Connection(2)-127.0.0.1] org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.initControllerAdviceCache Looking for @ControllerAdvice: Root WebApplicationContext: startup date [Tue Feb 16 21:15:34 CET 2016]; root of context hierarchy
16-Feb-2016 21:15:36.443 INFO [RMI TCP Connection(2)-127.0.0.1] org.springframework.web.servlet.handler.SimpleUrlHandlerMapping.registerHandler Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
16-Feb-2016 21:15:36.502 INFO [RMI TCP Connection(2)-127.0.0.1] org.springframework.web.context.ContextLoader.initWebApplicationContext Root WebApplicationContext: initialization completed in 2044 ms
16-Feb-2016 21:15:36.518 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal One or more Filters failed to start. Full details will be found in the appropriate container log file
16-Feb-2016 21:15:36.519 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
16-Feb-2016 21:15:36.531 INFO [RMI TCP Connection(2)-127.0.0.1] org.springframework.web.context.support.XmlWebApplicationContext.doClose Closing Root WebApplicationContext: startup date [Tue Feb 16 21:15:34 CET 2016]; root of context hierarchy
[2016-02-16 09:15:36,567] Artifact SpringMVCVezba2:war exploded: Error during artifact deployment. See server log for details.
【问题讨论】:
-
一个或多个过滤器无法启动。完整的详细信息将在相应的容器日志文件中找到
-
@wero 问题是,我不知道在哪里可以找到。
-
Tomcat 是你的容器。它的日志在 tomcat/logs 中。查找名为
catalina<date>.log的最新日志文件,并尝试在末尾找到错误堆栈跟踪。 -
@wero 啊,好吧,我会尝试从那里解决。谢谢。
-
只是为了补充:
/var/logs/tomcat8中的日志不显示所有堆栈跟踪。转到 tomcat 路径以获取完整日志。默认安装在/usr/share/tomcat8/logs
标签: java xml spring maven spring-mvc