4

I know there are a ton of similar questions like this, but I can't seem to find the answer for Spring Boot 2. I am getting this error:

Caused by: org.apache.jasper.JasperException: The absolute uri: [http://www.springframework.org/security/tags] 
cannot be resolved in either web.xml or the jar files deployed with this application

So I looked into the /work directory and found the java of the jsp, and found this line:

_jspx_dependants.put("/WEB-INF/lib/spring-security-taglibs-3.2.0.RELEASE.jar", Long.valueOf(1524843694000L));

Now my pom has it at spring-security-taglibs-5.0.6.RELEASE.jar and that is in the /lib directory.

I am also using apache tiles 3.0.5. Don't know if that maters at all.

Here are my pom entries:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>        
</dependency>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-jdbc</artifactId>
        </exclusion>
    </exclusions>       
</dependency>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
</dependency>

<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-taglibs</artifactId>
</dependency>   

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-messaging</artifactId>
</dependency>   

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-websocket</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-jasper</artifactId>
    <scope>provided</scope>
</dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <scope>provided</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.servlet.jsp/jsp-api -->
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.2</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
    </dependency>

<!--  Tiles -->
<dependency>
    <groupId>org.apache.tiles</groupId>
    <artifactId>tiles-jsp</artifactId>
    <version>${apache.tiles.version}</version>
</dependency>

<dependency>
    <groupId>org.apache.tiles</groupId>
    <artifactId>tiles-core</artifactId>
    <version>${apache.tiles.version}</version>
    <scope>compile</scope>
</dependency>

<dependency>
    <groupId>org.apache.tiles</groupId>
    <artifactId>tiles-api</artifactId>
    <version>${apache.tiles.version}</version>
    <scope>compile</scope>
</dependency>

<dependency>
    <groupId>org.apache.tiles</groupId>
    <artifactId>tiles-servlet</artifactId>
    <version>${apache.tiles.version}</version>
</dependency>

<dependency>
    <groupId>org.apache.tiles</groupId>
    <artifactId>tiles-template</artifactId>
    <version>${apache.tiles.version}</version>
</dependency>

Any ideas how that version gets into the java of the jsp?

UPDATE I no longer think it's a Spring Boot 2 problem. I reverted to boot 1.5.15 and I got the same error. I even reverted further back to a simple spring project (4.3.18.RELEASE and spring-security 4.2.7.RELEASE) and I get the same error. If, however, I revert all the way back to spring security 3.2.0, it works.

I must have a dependency conflict somewhere, or the old security version is including a dependency that 4.x is not.

I have also discovered that the regular spring tags cannot be found either. IE:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%> 

is throwing an error about not finding http://www.springframework.org/tags and if I switch the order of "spring" and "sec" I get the error for which ever tag lib is first. BUT -- I do not get an error for http://java.sun.com/jsp/jstl/core so it's not a general "loading taglib" error.

mmaceachran
  • 3,178
  • 7
  • 53
  • 102
  • I would look at the dependency hierarchy for your pom.xml in eclipse, to see whether any of your dependencies are bringing in an earlier version of Spring than you meant to use. – moilejter Aug 08 '18 at 06:02
  • There could be an issue with how you're packaging your app, if you're trying to build a single-jar artifact. This answer might help: https://stackoverflow.com/questions/51718271/combine-multiple-module-jars-into-a-single-one/51718764#51718764 - it's the way I've used Maven shade to build single-jar artifacts, preserving the right metadata files for all my dependencies. – moilejter Aug 08 '18 at 06:04
  • I looked at the hierarchy, and the WEB-INF/lib folder of the war, and it is not bringing in an old version. Also, I do not believe that is a packing problem as all I have to do is change the spring-secrutiy version to 3.x and it works. – mmaceachran Aug 08 '18 at 14:06
  • have you run mavens dependency tree to see if there are any warnings: mvn dependency:tree? – karen Aug 08 '18 at 15:30

1 Answers1

0

As I faced the same issue, while configuring the spring security using spring boot for 2.1.3 version. Not sure why this happens.

The spring security boot version wont add the tablib library. You have to add it manually if you are using it in jsp.

Add this line in your pom.xml file and it resolved the dependency.

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId></dependency>

Hope this helps someone.

Atul
  • 3,043
  • 27
  • 39