2012-04-18 42 views
5

Tôi đang thử thiết lập bảo mật mùa xuân cơ bản. Tôi đang sử dụng 3.1.0.RELEASE tôi có trong xml an ninh mùa xuân như sau:Bảo mật mùa xuân-Lỗi khi tạo bean 'org.springframework.security.filterChains'

<security:http auto-config='true'> 
<security:intercept-url pattern="/**" access="ROLE_USER" /> 
</security:http> 

<security:authentication-manager> 
<security:authentication-provider> 
<security:user-service> 
<security:user name="jimi" password="jimispassword" authorities="ROLE_USER,  ROLE_ADMIN" /> 
<security:user name="bob" password="bobspassword" authorities="ROLE_USER" /> 
</security:user-service> 
</security:authentication-provider> 
</security:authentication-manager> 

Khi tôi truy cập vào trang bắt đầu, tôi nhận được ngoại lệ sau đây: org.springframework.beans.factory.BeanCreationExce ption : Lỗi khi tạo bean có tên 'org.springframework.security.filterChains': Khởi tạo bean không thành công; ngoại lệ lồng nhau là java.lang.NoSuchFieldError: NULL.

Bất kỳ ai có thể giúp tôi không?

+0

org.springframework.beans.factory.BeanCreationException: Lỗi khi tạo bean có tên 'org.springframework.security.filterChains': Khởi tạo bean không thành công; ngoại lệ lồng nhau là java.lang.NoSuchFieldError: NULL \t tại org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.java WEBC27) – jrpalla

+0

**************** ********** web xml *********** contextConfigLocation /WEB-INF/applicationContext-security.xml springSecurityFilterChain org.springframework.web.filter.DelegatingFilterProxy springSecurityFilterChain /* jrpalla

+1

Chào mừng bạn đến Stackoverflow. Một gợi ý: thay vì thêm lệnh, bạn có thể chỉnh sửa câu hỏi, điều này sẽ làm cho nó dễ đọc hơn. – Ralph

Trả lời

0

web.xml của bạn trông giống như bạn bỏ lỡ org.springframework.web.context.ContextLoaderListener

bạn web.xml shoul có những yếu tố này:

<!-- or in your case /WEB-INF/applicationContext-security.xml --> 
<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value>classpath*:META-INF/spring/applicationContext*.xml</param-value> 
</context-param> 

<filter> 
    <filter-name>springSecurityFilterChain</filter-name> 
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> 
</filter> 

<servlet> 
    <servlet-name>My-Web-SpringProject</servlet-name> 
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
    <init-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value>/WEB-INF/spring/webmvc-config.xml</param-value> 
    </init-param> 
    <load-on-startup>1</load-on-startup> 
</servlet> 

<filter-mapping> 
    <!-- do not change this name! --> 
    <filter-name>springSecurityFilterChain</filter-name> 
    <url-pattern>/*</url-pattern> 
</filter-mapping> 

<!-- Creates the Spring Container shared by all Servlets and Filters --> 
<!-- it is configured by the parameter contextConfigLocation in the begining --> 
<listener> 
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
</listener> 

<servlet-mapping> 
    <servlet-name>My-Web-SpringProject</servlet-name> 
    <url-pattern>/</url-pattern> 
</servlet-mapping> 

Thành thật mà nói, đây là một cấu hình Spring 3.0, nhưng tôi nghĩ rằng nó là như nhau cho 3.1

11

Nguyên nhân thực sự của vấn đề dường như là bảo mật mùa xuân 3.1.0 kéo trong các phiên bản cũ của mùa xuân tạo ra xung đột thầm lặng. Trong trường hợp của tôi spring-security-3.1.0.RELEASE đã kéo vào spring-aop, spring-jdbc, spring-tx và spring-expression 3.0.6 nhưng tôi đã sử dụng spring 3.1.0.RELEASE. Sau khi thêm những phụ thuộc này một cách rõ ràng vấn đề đã biến mất.

+0

đây là chẩn đoán chính xác, thêm quản lý dep cho aop/jdbc/etc và nó sẽ sửa lỗi: – ianpojman

Các vấn đề liên quan