rapt
rapt

Reputation: 12230

Spring-Security 3.1 java.lang.ClassNotFoundException: org.springframework.security.taglibs.authz.AuthorizeTag

I just upgraded from Spring Security 3.0.5 to 3.1.0.RC3

Now, the following JSP code gives me java.lang.ClassNotFoundException: org.springframework.security.taglibs.authz.AuthorizeTag

<security:authorize access="not hasRole('ROLE_ANONYMOUS')">
Welcome <%= request.getUserPrincipal().getName() %>
</security:authorize>

I look at the Spring Security Reference Documentation 3.1 and it looks like the <security:authorize> tag should work. However when I look at the directory org.springframework.security.taglibs.authz in spring-security-taglibs-3.1.0.RC3.jar I cannot see any AuthorizeTag.class there.

What is wrong here?

Thanks!

Upvotes: 9

Views: 7989

Answers (5)

VISHAL PATEL
VISHAL PATEL

Reputation: 31

To solve this issue in Spring MVC,

You need to add jar/dependency in pom.xml file.

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${springsecurity.version}</version>
</dependency>

After adding taglib jar file, you have to import package into your JSP file.

<%@ page import="org.springframework.security.taglibs.authz.JspAuthorizeTag "%> 

Please remove taglib Uri from your JSP file <%@ taglib prefix="authz" uri="http://www.springframework.org/security/tags"%>

Upvotes: 0

CamelTM
CamelTM

Reputation: 1250

Try to update the security.tld (3.0.0.RELEASE):

<tag-class>org.springframework.security.taglibs.authz.AuthorizeTag</tag-class>

to

<tag-class>org.springframework.security.taglibs.authz.JspAuthorizeTag</tag-class>

It's work for my configuration project with FreeMarker

<#assign security=JspTaglibs["/WEB-INF/tlds/security.tld"] />

(mvn jetty:run and mvn tomcat:run). ;-)

Upvotes: 1

aki
aki

Reputation: 1761

it is renamed to JspAuthorizeTag

(org.springframework.security.taglibs.authz.JspAuthorizeTag)

Upvotes: 2

Simon
Simon

Reputation: 281

I found that Tomcat might cache the old security.tld, even the spring security library are all 3.1 version. Delete the Tomcat work directory and restart it would works fine now.

Upvotes: 28

axtavt
axtavt

Reputation: 242696

I guess you have an old security.tld file somewhere. Make sure that you haven't copied it into your WEB-INF and that you don't have any old Spring Security jars in your classpath.

Upvotes: 1

Related Questions