Error: IllegalArgumentException - Spring security. Please give me a solution

137 Views Asked by At

I'm doing with spring security. When i browser http://localhost:8080/rest/user/json/quypham then occur following error:

[WARNING] /rest/user/json/quypham java.lang.IllegalArgumentException: Failed to evaluate expression 'ROLE_ADMIN' at org.springframework.security.access.expression.ExpressionUtils.evalua teAsBoolean(ExpressionUtils.java:15) at org.springframework.security.web.access.expression.WebExpressionVoter .vote(WebExpressionVoter.java:36) at org.springframework.security.web.access.expression.WebExpressionVoter .vote(WebExpressionVoter.java:18) at org.springframework.security.access.vote.AffirmativeBased.decide(Affi rmativeBased.java:62) at org.springframework.security.access.intercept.AbstractSecurityInterce ptor.beforeInvocation(AbstractSecurityInterceptor.java:232) at org.springframework.security.web.access.intercept.FilterSecurityInter

Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E: (pos 0): Property or field 'ROLE_ADMIN' cannot be found on object of type 'org.s pringframework.security.web.access.expression.WebSecurityExpressionRoot' - maybe not public? at org.springframework.expression.spel.ast.PropertyOrFieldReference.read Property(PropertyOrFieldReference.java:215) at org.springframework.expression.spel.ast.PropertyOrFieldReference.getV alueInternal(PropertyOrFieldReference.java:85) at org.springframework.expression.spel.ast.PropertyOrFieldReference.getV alueInternal(PropertyOrFieldReference.java:78) at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(Sp elNodeImpl.java:114) at org.springframework.expression.spel.standard.SpelExpression.getValue( SpelExpression.java:105) at org.springframework.security.access.expression.ExpressionUtils.evalua

I think to have wrong somthing in file userservice-servlet.xml, please let me know.

Here file userservice-servlet.xml

<security:http>
    <security:http-basic/>
    <security:intercept-url pattern="/rest/**" access="ROLE_ADMIN"/>            
</security:http>

<security:authentication-manager alias="authenticationManager">
    <security:authentication-provider>
        <security:user-service>
            <security:user name="datpham" password="Dat12345" authorities="ROLE_ADMIN"/>
            <security:user name="hoaipham" password="Hoai12345" authorities="ROLE_USER"/>
        </security:user-service>
    </security:authentication-provider>
</security:authentication-manager>
1

There are 1 best solutions below

0
Dat Pham On

I have replace spring-security-web and spring-security-config version 4.0.3 to version 3.2.4.. Everything run ok, But i don't understand why ????