5

Spring Security を extjs プロジェクトに統合しようとしていますが、次のエラーが発生しました。全体のスタックトレースは.

 SEVERE: Exception starting filter springSecurityFilterChain
 org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined
at           org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:510)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1056)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:274)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1049)
at org.springframework.web.filter.DelegatingFilterProxy.initDelegate(DelegatingFilterProxy.java:217)
at org.springframework.web.filter.DelegatingFilterProxy.initFilterBean(DelegatingFilterProxy.java:145)
at org.springframework.web.filter.GenericFilterBean.init(GenericFilterBean.java:179)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:269)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:250)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:368)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:98)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4211)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4837)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1028)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:773)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1028)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:278)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:429)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:662)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.startup.Catalina.start(Catalina.java:592)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:290)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:418)
    Apr 30, 2012 1:05:00 PM org.apache.catalina.core.StandardContext startInternal
    SEVERE: Error filterStart    

私のweb.xmlは次のとおりです

   <?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>extjs-crud-grid-spring-hibernate</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>


 <listener>
 <listener-  class>org.springframework.web.context.ContextLoaderListener</listener- class>
 </listener>


<servlet>
<servlet-name>extjs-crud-grid-spring-hibernate</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
 <param-name>contextConfigLocation</param-name>
     <param-value>
            /WEB-INF/applicationContext.xml
            /WEB-INF/applicationContext-security.xml
     </param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>extjs-crud-grid-spring-hibernate</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping>

applicationContext.xml は

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

<!-- Scans the classpath of this application for @Components to deploy as beans -->
<!-- Annotated controller beans may be defined explicitly, using a standard Spring bean definition in the 
dispatcher's context. However, the @Controller stereotype also allows for autodetection, aligned with Spring 2.5's 
general support for detecting component classes in the classpath and auto-registering bean definitions for them. -->
<context:component-scan base-package="com.loiane" />

<!-- Configures the @Controller programming model -->
<mvc:annotation-driven />

<!-- misc -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
    <property name="suffix" value=".jsp"/>
</bean>

<!-- Configures Hibernate - Database Config -->
<import resource="db-config.xml" />

applicationContext-security.xml

   <?xml version="1.0" encoding="UTF-8"?>

    <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:security="http://www.springframework.org/schema/security"
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-2.0.xsd
    http://www.springframework.org/schema/security  http://www.springframework.org/schema/security/spring-security-2.0.xsd">

<security:global-method-security />
<security:http auto-config="false" entry-point-ref="authenticationProcessingFilterEntryPoint">
    <security:intercept-url pattern="/index.jsp" filters="none" />
    <security:intercept-url pattern="/*.action" access="ROLE_USER" />
</security:http>

<bean id="authenticationProcessingFilter" class="com.loiane.security.MyAuthenticationProcessingFilter">
    <security:custom-filter position="AUTHENTICATION_PROCESSING_FILTER" />
    <property name="defaultTargetUrl" value="/index.jsp" />
    <property name="authenticationManager" ref="authenticationManager" />
</bean>

<security:authentication-manager alias="authenticationManager" />

<bean id="authenticationProcessingFilterEntryPoint"
    class="org.springframework.security.ui.webapp.AuthenticationProcessingFilterEntryPoint">
    <property name="loginFormUrl" value="/index.jsp" />
    <property name="forceHttps" value="false" />
</bean>

<!--
Usernames/Passwords are
    rod/koala
    dianne/emu
    scott/wombat
    peter/opal
These passwords are from spring security app example    
-->
<security:authentication-provider>
    <security:password-encoder hash="md5"/>
    <security:user-service>
        <security:user name="options" password="22b5c9accc6e1ba628cedc63a72d57f8" authorities="ROLE_USER" />
    </security:user-service>
</security:authentication-provider>
 </beans>

他のスレッドを参照しましたが、解決策はありません。誰かが構成の問題を修正できますか?

時間をありがとう。

編集: 新しい問題はマッピングにあります。ここに私のコントローラクラスがあります.私は私の web.xml を上に持っています.私はSPring Securityを使用しています. ログインに成功した後、main.jsp に移動できません。メソッドの上に@RequestMapping アノテーションを追加しました。

コントローラ クラス

      @Controller

public class ContactController extends MultiActionController {

private ContactService contactService;

@RequestMapping(value="/contact/main.action")
public ModelAndView main(HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    return new ModelAndView("main.jsp");

}

@RequestMapping(value="/contact/view.action")
public @ResponseBody Map<String,? extends Object> view() throws Exception {

    try{

        List<Contact> contacts = contactService.getContactList();

        return getMap(contacts);

    } catch (Exception e) {

        return getModelMapError("Error retrieving Contacts from database.");
    }
}

@RequestMapping(value="/contact/create.action")
public @ResponseBody Map<String,? extends Object> create(@RequestParam Object data) throws Exception {

    try{
        List<Contact> contacts = contactService.create(data);

        return getMap(contacts);

    } catch (Exception e) {

        return getModelMapError("Error trying to create contact.");
    }
}
4

3 に答える 3

4

代わりに試してください:

 <param-value>
        /WEB-INF/applicationContext.xml
        /WEB-INF/applicationContext-security.xml
 </param-value>

/WEB-INF/applicationContext.xml で次の操作を行います。

<import resource="applicationContext-security.xml"/>
于 2013-02-25T12:33:46.537 に答える
4

コントローラーの問題について:実際にはマッピングがありません
/extjs-crud-grid-spring-hibernate/main.action

そのコントローラーでマッピングしているのは、たとえば次のとおりです。
/extjs-crud-grid-spring-hibernate/contact/main.action

最初の URI にアクセスする必要がある場合はcontact、コントローラーから " " を削除し、" " のみにマップする必要があります/main.action

Spring Security については、このチュートリアルが役立つことは確かです (または、グーグルで見つけられるほとんどすべてのチュートリアル)。しかし、本当にそれについて学びたい場合は、Spring の本 (Spring のレシピと Spring Security 3) を強くお勧めします。

于 2012-05-02T11:14:25.467 に答える