2014-07-08 17 views
1

嗨我想在weblogic 10.3.6上部署我的弹簧安全性的小弹簧webapp,并且我总是收到此错误:Weblogic Spring Security“在其他模式之前定义的通用匹配模式('/ **')”

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChainProxy': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: A universal match pattern ('/**') is defined before other patterns in the filter chain, causing them to be ignored. Please check the ordering in your <security:http> namespace or FilterChainProxy bean configuration 

我被读了关于重复根上下文和重复http重写我的secound上下文与默认http,其中第一个是/ **和遮蔽secound永远不会执行。 如何防止这种类型的错误和加载上下文只有一次?

的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:p="http://www.springframework.org/schema/p" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
     http://www.springframework.org/schema/context 
     http://www.springframework.org/schema/context/spring-context.xsd 
     http://www.springframework.org/schema/mvc 
     http://www.springframework.org/schema/mvc/spring-mvc.xsd"> 

    <!--bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" 
     p:location="/WEB-INF/jdbc.properties" /> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" 
     p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}" p:username="${jdbc.username}" 
     p:password="${jdbc.password}"/--> 

    <!-- ADD PERSISTENCE SUPPORT HERE (jpa, hibernate, etc) --> 


    <import resource="spring-security.xml" /> 

</beans> 

调度-servlet.xml中

<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" 
    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"> 

    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
     <property name="prefix"> 
      <value>/WEB-INF/jsp/</value> 
     </property> 
     <property name="suffix"> 
      <value>.jsp</value> 
     </property> 
    </bean> 

</beans> 

弹簧的security.xml

<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-3.0.xsd 
     http://www.springframework.org/schema/security 
     http://www.springframework.org/schema/security/spring-security-3.2.xsd"> 

<security:http auto-config="true"> 
    <security:intercept-url pattern="/**" access="ROLE_USER" /> 
    <security:form-login login-page="/login.jsp" default-target-url="/hello.jsp" always-use-default-target="true" /> 
</security:http> 

<security:http pattern="/login.jsp*" security="none"/> 

<security:authentication-manager> 
    <security:authentication-provider> 
     <security:user-service> 
      <security:user name="pawel" password="pawel1" authorities="ROLE_USER, ROLE_ADMIN" /> 
      <security:user name="bob" password="bob1" authorities="ROLE_USER" /> 
     </security:user-service> 
    </security:authentication-provider> 
</security:authentication-manager> 

的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" 
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> 


    <!-- Spring MVC --> 
    <servlet> 
     <servlet-name>dispatcher</servlet-name> 
     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
    </servlet> 

    <servlet-mapping> 
     <servlet-name>dispatcher</servlet-name> 
     <url-pattern>/</url-pattern> 
    </servlet-mapping> 

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

    <context-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value> 
      /WEB-INF/applicationContext.xml 
     </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> 
+0

http://stackoverflow.com/questions/20812698/的可能dublicate a-universal-match-pattern-is-defined-before-other-patterns-in-the-filter –

+0

B你有'/ **'作为你的''中的第一个模式。它是为了一个目的吗?错误按摩很有意义:其他模式将被忽略。 – Alexey

+0

我读过,但我仍然不知道如何修复我的配置。 – user3815507

回答

0

尝试移动:

<security:http pattern="/login.jsp*" security="none"/> 

上述

<security:http auto-config="true"> 
    <security:intercept-url pattern="/**" access="ROLE_USER" /> 
    <security:form-login login-page="/login.jsp" default-target-url="/hello.jsp" always-use-default-target="true" /> 
</security:http> 
+0

现在它正常工作,非常感谢您的帮助。 – user3815507