Websphere 7 — универсальный шаблон соответствия ('/**') определяется перед другими шаблонами

Я создал весенний проект, используя Roo, и использовал надстройку для настройки безопасности, чтобы добавить весеннюю безопасность. Безопасность работает нормально на Tomcat 7, но я столкнулся со следующей проблемой при попытке развернуть на Websphere 7.0.0.19. В настоящее время я использую Spring Security 3.1.0.RELEASE. Я видел, как другие проекты прекрасно используют Spring DelegatingFilterProxy в Websphere. У кого-нибудь есть идеи?

Ошибка от StackTrace:

E org.springframework.web.context.ContextLoader initWebApplicationContext Context initialization failed
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

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

    <!-- HTTP security configurations -->
    <http auto-config="true" use-expressions="true" >
        <form-login login-processing-url="/resources/j_spring_security_check" login-page="/login" authentication-failure-url="/login?login_error=t" />
        <logout logout-url="/resources/j_spring_security_logout" />
        <!-- Configure these elements to secure URIs in your application -->
        <intercept-url pattern="/login" access="permitAll" />
        <intercept-url pattern="/admin/**" access="hasRole('ROLE_ADMIN')" />
        <intercept-url pattern="/jobtypes/**" access="isAuthenticated()" />
        <intercept-url pattern="/tests/**" access="permitAll" />
        <!-- Websphere Problem: IllegalArgumentException: A universal match pattern ('/**') is defined  before other patterns in the filter chain -->
        <intercept-url pattern="/resources/**" access="permitAll" />
        <intercept-url pattern="/**" access="hasRole('ROLE_USER')" />
    </http>

    <!-- Configure Authentication mechanism -->
    <beans:bean name="myCompanyAuthenticationProvider" class="edu.mycompany.project.security.MyCompanyAuthenticationProvider" />
    <authentication-manager alias="authenticationManager">
        <authentication-provider ref="myCompanyAuthenticationProvider" />
    </authentication-manager>   
</beans:beans>

Спасибо,


person Isaac    schedule 23.05.2012    source источник


Ответы (2)



Интересно... Я использую Spring Security 3.1.0.RELEASE и также развертываю WAS 7, но у меня никогда не было проблем ни с одним из моих приложений. Единственная небольшая разница между вашим и моим в том, что я не использую выражения. Вот как выглядит мой: -

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

    <security:http auto-config="true">
        <security:form-login login-page="/" authentication-failure-url="/?login_error=1" default-target-url="/"
                             always-use-default-target="true"/>
        <security:logout logout-success-url="/" />
        <security:intercept-url pattern="/secure/**" access="ROLE_ADMIN,ROLE_USER"/>
        <security:intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
    </security:http>

    ...

</beans>

Еще одно ключевое отличие состоит в том, что мой универсальный /** открыт для анонимного доступа, тогда как ваш ограничен ROLE_USER.

person limc    schedule 15.08.2012
comment
Похоже, что с фактической конфигурацией не было проблем, просто конфигурация загружалась дважды. Спасибо за ответ. - person Isaac; 20.08.2012