I added the Spring sps jsp security tag to the freemarker template because I use freemarker to view my web application, not jsps. For those who are looking for how to install this, I found Adding a spring library to use Freemarker's JSP Taglib for security , to be a very useful question. In conclusion, add the following to the * .ftl file that you want to use in the tags:
<#assign security=JspTaglibs["http://www.springframework.org/security/tags"] />
Then, assuming you are using maven, add the following to your pom.xml:
<dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-taglibs</artifactId> <version>${spring.security.version}</version> </dependency>
Once I installed this, I ran the spring controller module tests, and all of them failed. The problem was that they needed el-api.jar and jsp-api.jar to decide how to render the Jsp tags. They are included as part of the container in which the web application (tomcat) is running, so they were not necessary for the application to function properly. So I added them as maven dependencies within the scope of the validation.
<dependency> <groupId>javax.el</groupId> <artifactId>el-api</artifactId> <version>2.2</version> <scope>test</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jsp-api</artifactId> <version>2.0</version> <scope>test</scope> </dependency>
With this fix, my tests also generated an error that they could not find the mapping for the .tld file, even if it was enabled when adding the maven-wec2 -security-taglibs dependencies.
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is freemarker.template.TemplateModelException: No mapping defined for http://www.springframework.org/security/tags The failing instruction (print stack trace for 2 more): ==> #assign security = JspTaglibs["http:/... [in template "global/menu.ftl" at line 1, column 1]
To fix this, I also had to add security.tld to WEB-INF / lib /. Everything works now, but itβs not very good that I need to have the security.tld tag library in two places (spring -security-taglibs-3.1.3.RELEASE.jar in the META-INF and WEB-INF / lib sections).
My question is: does anyone know how I can avoid this duplication of security.tld in two places in order to be able to run unit tests, would I rather just include it in the jar file and not add it to WEB-INF / Lib?