Spring Security Authorization Tag - HTTP Status 500

I am trying to hide or show some parts of a .jsp page using the authorize tag. I tried the following code: hasRole, isAuthenticated () or something else gives an error:

HTTP status 500 - org.apache.jasper.JasperException: exception processing JSP page

<sec:authorize access="hasRole('USER')"> show something </sec:authorize> 

Spring Security Configurations:

 <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.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd"> <http auto-config="true" > <intercept-url pattern="/" access="permitAll" /> <intercept-url pattern="/home/**" access="hasRole('USER')" /> <intercept-url pattern="/user/profile/**" access="hasRole('USER')" /> <form-login login-page="/login" username-parameter="ssoId" password-parameter="password" authentication-failure-url="/Access_Denied" /> <csrf/> </http> <authentication-manager > <authentication-provider> <jdbc-user-service data-source-ref="dataSource" users-by-username-query= "select USER_NAME, USER_PASS, USER_ENABLED from USERS where USER_NAME=?" authorities-by-username-query= "select USER_NAME, USER_ROLE from USER_ROLES where USER_NAME=?" /> </authentication-provider> </authentication-manager> </beans:beans> 

HTTP status 500 - javax.servlet.ServletException: java.lang.NoSuchMethodError: org.springframework.security.web.context.support.SecurityWebApplicationContextUtils.findWebApplicationContext (Ljavax / servlet / ServletContext;) Lorgpp springframe;

Exception Report Type

message javax.servlet.ServletException: java.lang.NoSuchMethodError: org.springframework.security.web.context.support.SecurityWebApplicationContextUtils.findWebApplicationContext (Ljavax / servlet / ServletContext;) Lorg / springframeworkpp

Description The server detected an internal error that prevented it from executing this request.

exceptions

org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.NoSuchMethodError: org.springframework.security.web.context.support.SecurityWebApplicationContextUtils.findWebApplicationContext (Ljavax / servlet context / Serlet; / WebApplicationContext; org.apache. java: 396) org.apache.jasper.servlet.JspServlet.service (JspServlet.javahaps40) javax.servlet.http.HttpServlet.service (HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter. doFilter (WsFilter.java:52) org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel (InternalResourceView.java:168) org.springframework.web.servlet.view.AbstractView.render (AbstractView.java:303) org. springframework.web.servlet.DispatcherServlet.render (DispatcherServlet.java:1244) org.springframework.web.servlet.DispatcherServlet.processDispatchResult (DispatcherServlet.java:1027) org.springframework.web.servlet.DispatcherServlet.DispatcherServlet. 971) org.springframework.web.servlet.DispatcherServlet.doService (Dispatc herServlet.java:893) org.springframework.web.servlet.FrameworkServlet.processRequest (FrameworkServlet.java:966) org.springframework.web.servlet.FrameworkServlet.doGet (FrameworkServlet.java:857) javax.servlet.httpHtt. service (HttpServlet.java:622) org.springframework.web.servlet.FrameworkServlet.service (FrameworkServlet.java:842) javax.servlet.http.HttpServlet.service (HttpServlet.java:729) org.apache.tomcat.webs. server.WsFilter.doFilter (WsFilter.java:52) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java data16) org.springframework.security.web.access.intercept.FilterSecurityInterceptorercepterercepter java: 126) org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter (FilterSecurityInterceptor.java:90) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.source security.web.access.ExceptionTransla tionFilter.doFilter (ExceptionTranslationFilter.java:114) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.javahaps30) org.springframework.security.web.session.SessionManagementFilter.doFilter.doFilter2do org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java data3030) VirtualFilterChain.doFilter (FilterChainProxy.java data) 3030. org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter (SecurityContextHolderAwareRequestFilter.java:169) org.springframeworkFearweilFerweilFerweilerchilweiter org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter (RequestCacheAwareFilter.java:48) org.springf ramework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.javahaps30) org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilterInternal (BasicAuthenticationFilter.java:158. doFilter (OncePerRequestFilter.java:107) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java data30) org.springframework.security.web.authentication.AbstractAuthenticationProcessingFulttertertertertertertertertertertertertertertertertertertertertertertertertertertertertertertertertertertertermeter springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.javahaps30) org.springframework.security.web.authentication.logout.LogoutFilter.doFilter (LogoutFilter.java:120) org.springframebopeChrome.seer VirtualFilterChain.doFilter (FilterChainProxy.javahaps30) org.springframework.security.web.csrf.CsrfFilter.doFilterInternal (CsrfFilter.java:96) org.springframe work. HeaderWriterFilter.java:64) org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:107) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter.avaChromePro WorkProamine web. FilterChainProxy.javahaps30) org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter (SecurityContextPersistenceFilter.java:91) org.springframework.securit y.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java data) 176) org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate (DelegatingFilterProxy.java data 44) org.springframework.web.filter.DelegatingFilterProxy.doFilter (DelegatingFilterProxy.java:261)

The main reason

javax.servlet.ServletException: java.lang.NoSuchMethodError: org.springframework.security.web.context.support.SecurityWebApplicationContextUtils.findWebApplicationContext (Ljavax / servlet / ServletContext;) Lorg / springframeApplication / Webframework / webcontext / webframework / webcontext / webcontext / webconframe / web org. home_jsp.java:221) org.apache.jasper.runtime.HttpJspBase.service (HttpJspBase.java:70) javax.servlet.http.HttpServlet.service (HttpServlet.java:729) org.apache.jasper.servlet.JspServlet. service (JspServletWrapper.java:438) org.apache.jasper.servlet.JspServlet.serviceJspFile (JspServlet.javahaps96) org.apache.jasper.servlet.JspServlet.service (JspServlet.javahaps40) javax.servlet.http. HttpServlet.service (HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter (WsFilter.java:52) org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel Internal org.springframework.web.servlet.view.AbstractView.render (AbstractView.java:303) org.springframework.web.servlet.DispatcherServlet.re nder (DispatcherServlet.java:1244) org.springframework.web.servlet.DispatcherServlet.processDispatchResult (DispatcherServlet.java:1027) org.springframework.web.servlet.DispatcherServlet.doDispatch (DispatcherServlet.jprwebwork. servlet.DispatcherServlet.doService (DispatcherServlet.java:893) org.springframework.web.servlet.FrameworkServlet.processRequest (FrameworkServlet.java:966) org.springframework.web.servlet.FrameworkServlet.doGet (FrameworkServletjava. servlet.http.HttpServlet.service (HttpServlet.java:622) org.springframework.web.servlet.FrameworkServlet.service (FrameworkServlet.java:842) javax.servlet.http.HttpServlet.service (HttpServlet.java:29 apache.tomcat.websocket.server.WsFilter.doFilter (WsFilter.java:52) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.javahaps16) org.springframework.security.web.access.access FilterSecurityInterceptor.invoke (FilterSecurityInterceptor.j ava: 126) org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter (FilterSecurityInterceptor.java:90) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.source security.web.access.ExceptionTranslationFilter.doFilter (ExceptionTranslationFilter.java:114) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.javahaps30) org.springframework.security.web.session SessionManagementFilter.java:122) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.javahaps30) org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter.source security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.javahaps30) org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilt er.doFilter (SecurityContextHolderAwareRequestFilter.java:169) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.javahaps30) org.springframework.security.web.savedrequest.Requestterachewareilware org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java data3030) OncePerRequestFilter.doFilter (OncePerRequestFilter.java:107) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.javahaps30) org.springframework.security.web.authenthentication.FerterAuterterter org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.javahaps30) org.springframew ork.security.web.authentication.logout.LogoutFilter.doFilter (LogoutFilter.java:120) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java∗30) org.springframework.serfweb.web.web.web CsrfFilter.doFilterInternal (CsrfFilter.java:96) org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:107) org.springframework.security.web.

java.lang.NoSuchMethodError: org.springframework.security.web.context.support.SecurityWebApplicationContextUtils.findWebApplicationContext (Ljavax / servlet / ServletContext;) Lorg / springframework / web / context / WebApplicationContext; org.springframework.security.web.context.support.SecurityWebApplicationContextUtils.findRequiredWebApplicationContext (SecurityWebApplicationContextUtils.java:46) org.springframework.security.taglibs.authz.AbstractAuthorizeTag.btag.gettagjetgej authz.AbstractAuthorizeTag.authorizeUsingAccessExpression (AbstractAuthorizeTag.java:127) org.springframework.security.taglibs.authz.AbstractAuthorizeTag.authorize (AbstractAuthorizeTag.java:99torg.aguttutaguttutaguttutaguttutaguttutagutthortagtutaguttutaguttutagutthortagtutaguttutagutthortagsputt.jutt.jt 54) org.apache.jsp.WEB_002dINF.views.home_jsp._jspx_meth_sec_005fauthorize_005f0 (home_jsp.javahaps15) org.apache.jsp.WEB_002dINF.views.home_jsp._jspService (home_jjsp.jas.jsp.jas.jsp.jas.jsp. org HttpJspBase.service (HttpJspBase.java:70) javax.servlet.http.HttpServlet.service (HttpServlet.java:729) org.apache.jasper.servlet.JspServletWrapper.service (JspServletWrapper.java:438) org.apache.jasper.servlet.JspServlet.serviceJspFile (JspServlet.javahaps96) org.apache.jasper.servlet.JspServlet.service (JspServlet.javahaps40) javax.servlet.http.HttpServlet.service (HttpServlet. 729) org.apache.tomcat.websocket.server.WsFilter.doFilter (WsFilter.java:52) org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel (InternalResourceView.java:168) org.springframework.b view.AbstractView.render (AbstractView.java:303) org.springframework.web.servlet.DispatcherServlet.render (DispatcherServlet.java:1244) org.springframework.web.servlet.DispatcherServlet.processDispatchResult (DispatcherServlet.java:1027) springframework.web.servlet.DispatcherServlet.doDispatch (DispatcherServlet.java:971) org.springframework.web.servlet.DispatcherServlet.doService (DispatcherServlet.java:893) org.springframework.web.servlet.FrameworkServletprocess 966) org.springframework.web.servlet.FrameworkServlet.doGet (Fr ameworkServlet.java:857) javax.servlet.http.HttpServlet.service (HttpServlet.java:622) org.springframework.web.servlet.FrameworkServlet.service (FrameworkServlet.java:842) javax.servlet.http.HttServ HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter (WsFilter.java:52) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.javaf16work.sq. security.web.access.intercept.FilterSecurityInterceptor.invoke (FilterSecurityInterceptor.java:126) org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter (FilterSecurityInterceptor.java:90) org.springChainframeworkwork VirtualFilterChain.doFilter (FilterChainProxy.javahaps30) org.springframework.security.web.access.ExceptionTranslationFilter.doFilter (ExceptionTranslationFilter.java:114) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain Filter org.sp ringframework.security.web.session.SessionManagementFilter.doFilter (SessionManagementFilter.java:122) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java liver30) org.springframework.uthentn. doFilter (AnonymousAuthenticationFilter.java:111) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java:330) org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter (SecurityContextHolderAwareRequestFilter.java:169) org. springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.javahaps30) org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter (RequestCacheAwareFilter.java:48) org.springChainfil.filchain.ililfain.filterain doFilter (FilterChainProxy.javahaps30) org.springframework.security.web.authentication.www.BasicAuthenticationFilte r.doFilterInternal (BasicAuthenticationFilter.java:158) org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:107) org.springframework.security.web.FilterChainProxy. VirtualFilter.org springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter (AbstractAuthenticationProcessingFilter.java:205) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFourter.workfog.workfog.org LogoutFilter.doFilter (LogoutFilter.java:120) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java//30) org.springframework.security.web.csrf.CsrfFilter.ffrterrilfilrilrilrilrilrilrilrilfilrilrilfilter org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter.java:107) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProx y.javaIf3030) web. OncePerRequestFilter.java:107) org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.java{30) org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilterj.FerterFerterFenceterContext security.web.FilterChainProxy $ VirtualFilterChain.doFilter (FilterChainProxy.javahaps30) org.springframework.security.web.FilterChainProxy.doFilterInternal (FilterChainProxy.java:213 ) org.springframework.security.web.FilterChainProxy.doFilter (FilterChainProxy.java:176) org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate (DelegatingFilterProxy.javahaps44FlegterFilterFilterFilterFilterFilterFilterProilterililterililterililterililterililterililterililterililterililterililterililterililterililterililterililterililter .java: 261)

+6
source share
2 answers

I found where the problem is, I used a slightly lower version of the spring framework.

+8
source

it is not only associated with the spring version, but also takes care of version compatibility, the same thing happened to me on spring 4.1.6 and spring security 4.0.3, but it was decided when updating spring to version 4.2.2. here is a useful link for compatible versions. https://mvnrepository.com/artifact/org.springframework.security/spring-security-taglibs

0
source

All Articles