BlackkamemRaider 10 de abr. de 2017
Pessoal, fiz uma pequena alteração e apareceu um erro que ainda não encontrei a solução.
java . lang . IllegalArgumentException : Failed to evaluate expression ' ROLE_ADMIN '
at org . springframework . security . access . expression . ExpressionUtils . evaluateAsBoolean ( ExpressionUtils . java : 30 ) ~ [ spring - security - core - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . access . expression . WebExpressionVoter . vote ( WebExpressionVoter . java : 52 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . access . expression . WebExpressionVoter . vote ( WebExpressionVoter . java : 33 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . access . vote . AffirmativeBased . decide ( AffirmativeBased . java : 63 ) ~ [ spring - security - core - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . access . intercept . AbstractSecurityInterceptor . beforeInvocation ( AbstractSecurityInterceptor . java : 233 ) ~ [ spring - security - core - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . access . intercept . FilterSecurityInterceptor . invoke ( FilterSecurityInterceptor . java : 124 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . access . intercept . FilterSecurityInterceptor . doFilter ( FilterSecurityInterceptor . java : 91 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . FilterChainProxy $ VirtualFilterChain . doFilter ( FilterChainProxy . java : 331 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . access . ExceptionTranslationFilter . doFilter ( ExceptionTranslationFilter . java : 115 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . FilterChainProxy $ VirtualFilterChain . doFilter ( FilterChainProxy . java : 331 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . session . SessionManagementFilter . doFilter ( SessionManagementFilter . java : 137 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . FilterChainProxy $ VirtualFilterChain . doFilter ( FilterChainProxy . java : 331 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . authentication . AnonymousAuthenticationFilter . doFilter ( AnonymousAuthenticationFilter . java : 111 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . FilterChainProxy $ VirtualFilterChain . doFilter ( FilterChainProxy . java : 331 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . servletapi . SecurityContextHolderAwareRequestFilter . doFilter ( SecurityContextHolderAwareRequestFilter . java : 169 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . FilterChainProxy $ VirtualFilterChain . doFilter ( FilterChainProxy . java : 331 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . savedrequest . RequestCacheAwareFilter . doFilter ( RequestCacheAwareFilter . java : 63 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . FilterChainProxy $ VirtualFilterChain . doFilter ( FilterChainProxy . java : 331 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . authentication . AbstractAuthenticationProcessingFilter . doFilter ( AbstractAuthenticationProcessingFilter . java : 200 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . FilterChainProxy $ VirtualFilterChain . doFilter ( FilterChainProxy . java : 331 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . authentication . logout . LogoutFilter . doFilter ( LogoutFilter . java : 121 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . FilterChainProxy $ VirtualFilterChain . doFilter ( FilterChainProxy . java : 331 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . csrf . CsrfFilter . doFilterInternal ( CsrfFilter . java : 100 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . web . filter . OncePerRequestFilter . doFilter ( OncePerRequestFilter . java : 107 ) ~ [ spring - web - 4.3.5 . RELEASE . jar : 4.3.5 . RELEASE ]
at org . springframework . security . web . FilterChainProxy $ VirtualFilterChain . doFilter ( FilterChainProxy . java : 331 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . header . HeaderWriterFilter . doFilterInternal ( HeaderWriterFilter . java : 66 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . web . filter . OncePerRequestFilter . doFilter ( OncePerRequestFilter . java : 107 ) ~ [ spring - web - 4.3.5 . RELEASE . jar : 4.3.5 . RELEASE ]
at org . springframework . security . web . FilterChainProxy $ VirtualFilterChain . doFilter ( FilterChainProxy . java : 331 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . context . SecurityContextPersistenceFilter . doFilter ( SecurityContextPersistenceFilter . java : 105 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . FilterChainProxy $ VirtualFilterChain . doFilter ( FilterChainProxy . java : 331 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . context . request . async . WebAsyncManagerIntegrationFilter . doFilterInternal ( WebAsyncManagerIntegrationFilter . java : 56 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . web . filter . OncePerRequestFilter . doFilter ( OncePerRequestFilter . java : 107 ) ~ [ spring - web - 4.3.5 . RELEASE . jar : 4.3.5 . RELEASE ]
at org . springframework . security . web . FilterChainProxy $ VirtualFilterChain . doFilter ( FilterChainProxy . java : 331 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . FilterChainProxy . doFilterInternal ( FilterChainProxy . java : 214 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . security . web . FilterChainProxy . doFilter ( FilterChainProxy . java : 177 ) ~ [ spring - security - web - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
at org . springframework . web . filter . DelegatingFilterProxy . invokeDelegate ( DelegatingFilterProxy . java : 346 ) ~ [ spring - web - 4.3.5 . RELEASE . jar : 4.3.5 . RELEASE ]
at org . springframework . web . filter . DelegatingFilterProxy . doFilter ( DelegatingFilterProxy . java : 262 ) ~ [ spring - web - 4.3.5 . RELEASE . jar : 4.3.5 . RELEASE ]
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 192 ) ~ [ tomcat - embed - core - 8.5.6 . jar : 8.5.6 ]
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 165 ) ~ [ tomcat - embed - core - 8.5.6 . jar : 8.5.6 ]
at org . springframework . web . filter . RequestContextFilter . doFilterInternal ( RequestContextFilter . java : 99 ) ~ [ spring - web - 4.3.5 . RELEASE . jar : 4.3.5 . RELEASE ]
at org . springframework . web . filter . OncePerRequestFilter . doFilter ( OncePerRequestFilter . java : 107 ) ~ [ spring - web - 4.3.5 . RELEASE . jar : 4.3.5 . RELEASE ]
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 192 ) ~ [ tomcat - embed - core - 8.5.6 . jar : 8.5.6 ]
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 165 ) ~ [ tomcat - embed - core - 8.5.6 . jar : 8.5.6 ]
at org . springframework . web . filter . HttpPutFormContentFilter . doFilterInternal ( HttpPutFormContentFilter . java : 89 ) ~ [ spring - web - 4.3.5 . RELEASE . jar : 4.3.5 . RELEASE ]
at org . springframework . web . filter . OncePerRequestFilter . doFilter ( OncePerRequestFilter . java : 107 ) ~ [ spring - web - 4.3.5 . RELEASE . jar : 4.3.5 . RELEASE ]
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 192 ) ~ [ tomcat - embed - core - 8.5.6 . jar : 8.5.6 ]
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 165 ) ~ [ tomcat - embed - core - 8.5.6 . jar : 8.5.6 ]
at org . springframework . web . filter . HiddenHttpMethodFilter . doFilterInternal ( HiddenHttpMethodFilter . java : 77 ) ~ [ spring - web - 4.3.5 . RELEASE . jar : 4.3.5 . RELEASE ]
at org . springframework . web . filter . OncePerRequestFilter . doFilter ( OncePerRequestFilter . java : 107 ) ~ [ spring - web - 4.3.5 . RELEASE . jar : 4.3.5 . RELEASE ]
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 192 ) ~ [ tomcat - embed - core - 8.5.6 . jar : 8.5.6 ]
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 165 ) ~ [ tomcat - embed - core - 8.5.6 . jar : 8.5.6 ]
at org . springframework . web . filter . CharacterEncodingFilter . doFilterInternal ( CharacterEncodingFilter . java : 197 ) ~ [ spring - web - 4.3.5 . RELEASE . jar : 4.3.5 . RELEASE ]
at org . springframework . web . filter . OncePerRequestFilter . doFilter ( OncePerRequestFilter . java : 107 ) ~ [ spring - web - 4.3.5 . RELEASE . jar : 4.3.5 . RELEASE ]
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 192 ) ~ [ tomcat - embed - core - 8.5.6 . jar : 8.5.6 ]
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 165 ) ~ [ tomcat - embed - core - 8.5.6 . jar : 8.5.6 ]
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 198 ) ~ [ tomcat - embed - core - 8.5.6 . jar : 8.5.6 ]
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 108 ) [ tomcat - embed - core - 8.5.6 . jar : 8.5.6 ]
at org . apache . catalina . authenticator . AuthenticatorBase . invoke ( AuthenticatorBase . java : 472 ) [ tomcat - embed - core - 8.5.6 . jar : 8.5.6 ]
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 140 ) [ tomcat - embed - core - 8.5.6 . jar : 8.5.6 ]
at org . apache . catalina . valves . ErrorReportValve . invoke ( ErrorReportValve . java : 79 ) [ tomcat - embed - core - 8.5.6 . jar : 8.5.6 ]
at org . apache . catalina . core . StandardEngineValve . invoke ( StandardEngineValve . java : 87 ) [ tomcat - embed - core - 8.5.6 . jar : 8.5.6 ]
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 349 ) [ tomcat - embed - core - 8.5.6 . jar : 8.5.6 ]
at org . apache . coyote . http11 . Http11Processor . service ( Http11Processor . java : 784 ) [ tomcat - embed - core - 8.5.6 . jar : 8.5.6 ]
at org . apache . coyote . AbstractProcessorLight . process ( AbstractProcessorLight . java : 66 ) [ tomcat - embed - core - 8.5.6 . jar : 8.5.6 ]
at org . apache . coyote . AbstractProtocol $ ConnectionHandler . process ( AbstractProtocol . java : 802 ) [ tomcat - embed - core - 8.5.6 . jar : 8.5.6 ]
at org . apache . tomcat . util . net . NioEndpoint $ SocketProcessor . doRun ( NioEndpoint . java : 1410 ) [ tomcat - embed - core - 8.5.6 . jar : 8.5.6 ]
at org . apache . tomcat . util . net . SocketProcessorBase . run ( SocketProcessorBase . java : 49 ) [ tomcat - embed - core - 8.5.6 . jar : 8.5.6 ]
at java . util . concurrent . ThreadPoolExecutor . runWorker ( ThreadPoolExecutor . java : 1142 ) [ na : 1.8.0 _121 ]
at java . util . concurrent . ThreadPoolExecutor $ Worker . run ( ThreadPoolExecutor . java : 617 ) [ na : 1.8.0 _121 ]
at org . apache . tomcat . util . threads . TaskThread $ WrappingRunnable . run ( TaskThread . java : 61 ) [ tomcat - embed - core - 8.5.6 . jar : 8.5.6 ]
at java . lang . Thread . run ( Thread . java : 745 ) [ na : 1.8.0 _121 ]
Caused by : org . springframework . expression . spel . SpelEvaluationException : EL1008E : Property or field ' ROLE_ADMIN ' cannot be found on object of type ' org . springframework . security . web . access . expression . WebSecurityExpressionRoot ' - maybe not public ?
at org . springframework . expression . spel . ast . PropertyOrFieldReference . readProperty ( PropertyOrFieldReference . java : 224 ) ~ [ spring - expression - 4.3.5 . RELEASE . jar : 4.3.5 . RELEASE ]
at org . springframework . expression . spel . ast . PropertyOrFieldReference . getValueInternal ( PropertyOrFieldReference . java : 94 ) ~ [ spring - expression - 4.3.5 . RELEASE . jar : 4.3.5 . RELEASE ]
at org . springframework . expression . spel . ast . PropertyOrFieldReference . getValueInternal ( PropertyOrFieldReference . java : 81 ) ~ [ spring - expression - 4.3.5 . RELEASE . jar : 4.3.5 . RELEASE ]
at org . springframework . expression . spel . ast . SpelNodeImpl . getTypedValue ( SpelNodeImpl . java : 131 ) ~ [ spring - expression - 4.3.5 . RELEASE . jar : 4.3.5 . RELEASE ]
at org . springframework . expression . spel . standard . SpelExpression . getValue ( SpelExpression . java : 299 ) ~ [ spring - expression - 4.3.5 . RELEASE . jar : 4.3.5 . RELEASE ]
at org . springframework . security . access . expression . ExpressionUtils . evaluateAsBoolean ( ExpressionUtils . java : 26 ) ~ [ spring - security - core - 4.1.4 . RELEASE . jar : 4.1.4 . RELEASE ]
... 70 common frames omitted
edulemos 10 de abr. de 2017
Tenta fazer como abaixo, se ajudar tenho um projeto configurado com esta parte no github
.antMatchers("/alunos/").access("hasRole('USER)")
BlackkamemRaider 10 de abr. de 2017
@edulemos infelizmente não consegui implementar seguindo este projeto, para mim que estou iniciando as configurações deste outro projeto se torna complexa, pois esta bem diferente.
Com este código não da mais exception alguma, porem, nesta URLda acesso negado independente de qual função"ROLE" esteja, se eu colocar “ROLE_USER” como esta salvo no banco aparece a exception acima, qualquer outra variavel ou um texto qualquer continua aparecendo acesso negado para esta URL ;
".antMatchers("/alunos/novo").access("hasRole('USER')")"
@Override
protected void configure ( HttpSecurity http ) throws Exception {
http . authorizeRequests ()
. antMatchers ( "/home/**" ). permitAll ()
. antMatchers ( "/alunos/novo" ). access ( "hasRole('USER')" )
. and ()
. formLogin (). loginPage ( "/login" )
. usernameParameter ( "username" ). passwordParameter ( "password" )
. and ()
. logout (). logoutSuccessUrl ( "/login" ) ;
}