org.apache.sling.scripting.jsp.jasper.JasperException: Unable to load tag handler class [migrated]
- by Babak Behzadi
I'm developing an Apache Sling WCMS and using java tag libs to rendering some data.
I defined a jsp tag lib with following descriptor and handler class:
TLD file contains:
<?xml version="1.0" encoding="UTF-8"?>
<taglib version="2.1" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd">
<tlib-version>1.0</tlib-version>
<short-name>taglibdescriptor</short-name>
<uri>http://bob/taglibs</uri>
<tag>
<name>testTag</name>
<body-content>tagdependent</body-content>
<tag-class>org.bob.taglibs.test.TestTagHandler</tag-class>
</tag>
</taglib>
Tag handler class:
package org.bob.taglibs.test;
import javax.servlet.jsp.tagext.TagSupport;
public class TestTagHandler extends TagSupport{
@Override
public int doStartTag(){
try {
pageContext.getOut().print("<h1>Helloooooooo</h1>");
} catch(Exception e) {
return SKIP_BODY;
}
return EVAL_BODY_INCLUDE;
}
}
I packaged the tag lib as BobTagLib.jar and deployed it as a bundle using Sling Web Console.
I used this tag lib in a jsp page deployed in my Sling repository:
index.jsp:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="bob" uri="http://bob/taglibs" %>
<html>
<head><title>Simple jsp page</title></head>
<body>
<bob:testTag/>
</body>
</html>
Calling the page cause the following exception:
org.apache.sling.scripting.jsp.jasper.JasperException: /apps/TagTest/index.jsp(7,5) Unable to load tag handler class "org.bob.taglibs.test.TestTagHandler" for tag "bob:testTag"
...
Can any one get me a solution?
In advance, any help is apreciated.