user3495052
user3495052

Reputation: 243

Using Sling Taglib version 1.3 in a CQ5.6.1 project

I've been reading this article http://sling.apache.org/documentation/bundles/sling-scripting-jsp-taglib.html on the new Sling Taglib version 1.3 as I want to start using the new JSTL functions like listChildren, so that I can avoid Java scriptlets in my components.

When I use the taglib declaration

<%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling" %> 

in my component JSP, when I put the component into my PARSYS I get the following error

org.apache.sling.api.scripting.ScriptEvaluationException:
org.apache.sling.scripting.jsp.jasper.JasperException:
The absolute uri: http://sling.apache.org/taglibs/sling cannot be resolved
in either web.xml or the jar files deployed with this application

In my maven pom.xml file I have the dependency

<dependency>
    <groupId>org.apache.sling</groupId>
    <artifactId>org.apache.sling.scripting.jsp.taglib</artifactId>
    <version>2.2.0</version>
    <scope>provided</scope>
</dependency>

And the project builds correctly and installs correctly.

Does anyone know how to configure a CQ 5.6.1 project to use Sling Taglib Version 1.3 Bundle Version 2.2.0 with URI http://sling.apache.org/taglibs/sling?

Upvotes: 3

Views: 1457

Answers (1)

Tomek Rękawek
Tomek Rękawek

Reputation: 9304

CQ 5.6.1 contains org.apache.sling.scripting.jsp.taglib bundle in version 2.1.8 (which defines taglib in version 1.2). In order to use the new taglib, you need to upgrade the bundle.

If you define a Maven dependency as provided it means that it's already installed on the target platform. In this case it isn't true. Remove the scope or change it to compile in order to include the new taglib bundle to the CQ package. After package installation you can use all new features.

You may also install the bundle manually (via Felix console) - you won't need any Maven dependencies then.

Please notice that CQ may become unresponsive after installing new taglib bundle. Restarting instance should help.

Upvotes: 4

Related Questions