0

Webアプリケーションを開発するためにSpring-MVC(4.2.5)とSpring-Security(4.1.3)を使用しています。私は私のmvcプロジェクトに後者を組み込もうとしたときに問題が発生します。HTTPステータス500 - フィルタ実行が例外をスローしました - doFilterとinvokeDelegateが繰り返されました

現在、いくつかの試みの後、私はローカルホストで私tomeeサーバーでこのエラーを取得:8080/BetEx/

HTTP Status 500 - Filter execution threw an exception 

type Exception report 

message Filter execution threw an exception 

description The server encountered an internal error that prevented it from fulfilling this request. 

exception 

javax.servlet.ServletException: Filter execution threw an exception 
root cause 

java.lang.StackOverflowError 
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:246) 
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) 
[repeated many, many times] 

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>BetEx</display-name> 
    <welcome-file-list> 
     <welcome-file>index.html</welcome-file> 
    </welcome-file-list> 

    <!-- Spring MVC --> 
    <servlet> 
     <servlet-name>betex-controller</servlet-name> 
     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
     <load-on-startup>1</load-on-startup> 
    </servlet> 
    <servlet-mapping> 
     <servlet-name>betex-controller</servlet-name> 
     <url-pattern>/</url-pattern> 
    </servlet-mapping> 

    <!-- Spring Security Configuration File --> 
    <context-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value>/WEB-INF/spring/spring-security.xml</param-value> 
    </context-param> 
     <context-param> 
     <param-name>contextClass</param-name> 
     <param-value> 
     org.springframework.web.context.support.AnnotationConfigWebApplicationContext 
     </param-value> 
    </context-param> 

    <!-- Spring Security --> 
    <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> 
</web-app> 

betexコントローラサーブレット.xml

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xsi:schemaLocation=" 
    http://www.springframework.org/schema/beans  
    http://www.springframework.org/schema/beans/spring-beans-4.3.xsd 
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-4.3.xsd 
    http://www.springframework.org/schema/mvc 
    http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd"> 

    <context:component-scan base-package="controller" /> 
    <context:component-scan base-package="service" /> 

    <mvc:annotation-driven /> 

    <mvc:resources mapping="/resources/**" location="/resources/" /> 

    <bean id="templateResolver" 
     class="org.thymeleaf.templateresolver.ServletContextTemplateResolver"> 
     <property name="prefix" value="/WEB-INF/html/" /> 
     <property name="suffix" value=".html" /> 
     <property name="templateMode" value="HTML5" /> 
    </bean> 

    <bean id="templateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine"> 
     <property name="templateResolver" ref="templateResolver" /> 
    </bean> 

    <bean class="org.thymeleaf.spring4.view.ThymeleafViewResolver"> 
     <property name="templateEngine" ref="templateEngine" /> 
     <property name="order" value="1" /> 
    </bean> 

    <bean id="springSecurityFilterChain" class="org.springframework.web.filter.DelegatingFilterProxy" />  

</beans> 

春-のsecurity.xml

<?xml version="1.0" encoding="UTF-8"?> 
<beans:beans xmlns="http://www.springframework.org/schema/security" 
    xmlns:security="http://www.springframework.org/schema/security" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" 
    xsi:schemaLocation=" 
     http://www.springframework.org/schema/security 
     http://www.springframework.org/schema/security/spring-security-4.1.xsd 
     http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-4.3.xsd"> 

    <http pattern="/resources/**" security="none" /> 

    <http use-expressions="true"> 
     <intercept-url pattern="/index*" access="isAnonymous()" /> 
     <intercept-url pattern="/**" access="isAuthenticated()" /> 

     <form-login login-page='/index.html' default-target-url="/home.html" 
      authentication-failure-url="/index.html?error=true" /> 

     <logout logout-success-url="/index.html" /> 

    </http> 
    <authentication-manager> 
     <authentication-provider user-service-ref="customUserDetailsService"> 
      <password-encoder hash="bcrypt" /> 
     </authentication-provider> 
    </authentication-manager> 
</beans:beans> 

私は、このエラーは、フレームワークがDelegatingFilterProxy Beanをロードするために、アプリケーションのコンテキストにそれを委任することができないことを意味だと思います。

どこが間違っていますか?事前

EDITで ありがとう:

DUR

<bean id="springSecurityFilterChain" class="org.springframework.web.filter.DelegatingFilterProxy" /> 

により示唆されるように、私は、私のbetexコントローラ-servlet.xmlから次の行を削除した後、私は次のエラーがGETしよう私のWebアプリケーションのルートを開きます:

GRAVE: Servlet.service() for servlet [betex-controller] in context with path [/BetEx] threw exception 
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:698) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1175) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:284) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) 
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1060) 
    at org.springframework.web.filter.DelegatingFilterProxy.initDelegate(DelegatingFilterProxy.java:326) 
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:255) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) 
    at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44) 
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) 
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) 
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950) 
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) 
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070) 
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611) 
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 
    at java.lang.Thread.run(Thread.java:745) 
+0

が削除されました。別のエラーが表示されました(自分の投稿を編集しました)。私はそれを解決するために2日間、stackoverflowの多くの同様の記事を読んで、悪い結果で試しました。手伝って頂けますか? – andy

+0

まず、ご迷惑をおかけしていただきありがとうございます。私はすでに参照を読んだが、それでも私のエラーを修正することはできません。 spring-security.xmlは私のWARに存在します(別のEclipseプロジェクトでのエクスポートとインポートを試しました)。私はContextLoaderLister [リンク](http://stackoverflow.com/questions/12123516/getting-exception-no-bean-named-springsecurityfilterchain-is-defined)への最初の応答を読んだ後にこの投稿を削除しました。それを置き換える私はすべてのURIとサーバーの開始時に私の質問で同じ例外でHTTPステータス404を取得 – andy

答えて

0

すべての設定ファイルをダブルチェックした後、ドキュメンテーション、私は何も間違っていないという結論に達した。私は単にバージョン4.1.3から4.0.3へのダウングレードを解決しました

0

web xmlのurlパターンを変更してください。それはうまくいくはずです。

<filter-mapping> 
     <filter-name>springSecurityFilterChain</filter-name> 
     <url-pattern>/user/*</url-pattern> 
    </filter-mapping> 
関連する問題