"Unable to load tag handler class" after upgrading dependency versions to build the project with Java 11 and migrate to AEM 6.5

fcasamento

02-09-2020

I'm working on an AEM 6.4 maven project and I need to make it deployable on AEM 6.5.

 

First I updated the versions of some dependencies, in order to make the project buildable with java 11, and secondly I loaded the content into a new 6.5 instance.

The bundles run correctly, but when I try to access a page I get an error caused by the loading of a custom tag and the page appears all white:


org.apache.sling.scripting.jsp.jasper.JasperException: /apps/carnivol/framework/components/page/basepage/basepage.jsp(3,0) Unable to load tag handler class "com.carnivol.framework.utils.RemoveWhiteSpaceTag" for tag "carnivol:trim-white-space"

 

The same application works fine when compiled with java 8 (Apache Maven 3.6.3).

 

This is the java class the handles the new tag:

 

package com.carnivol.framework.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.BodyContent;
import javax.servlet.jsp.tagext.BodyTagSupport;

public class RemoveWhiteSpaceTag extends BodyTagSupport {

/** The Constant serialVersionUID. */
private static final long serialVersionUID = 2814639284705425046L;

/** The Constant LOGGER. */
private static final Logger LOGGER = LoggerFactory.getLogger(RemoveWhiteSpaceTag.class);

/*
* (non-Javadoc)
*
* @see javax.servlet.jsp.tagext.BodyTagSupport#doAfterBody()
*/
@Override
public int doAfterBody() {
try {
final BodyContent bodyContent = super.getBodyContent();
final JspWriter out = bodyContent.getEnclosingWriter();
final String html = bodyContent.getString();
out.print(html.replaceAll("(?m)^\\s+", ""));
} catch (IOException e) {
LOGGER.debug("remove white space error: ", e);
}
return SKIP_BODY;
}
}

 

This is the tld file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">
<tlib-version>1.0</tlib-version>
<short-name>trim-white-space</short-name>
<uri>http://www.carnivolcorp.com/trim-white-space</uri>
<tag>
<name>trim-white-space</name>
<tag-class>com.carnivol.framework.utils.RemoveWhiteSpaceTag</tag-class>
<body-content>scriptless</body-content>
</tag>
</taglib>

 

Here we have the jsp generating the error:

 

<%@include file="/libs/foundation/global.jsp"%><%@taglib
prefix="carnivol" uri="http://www.carnivolcorp.com/trim-white-space"%>
<carnivol:trim-white-space>
<cq:include script="basepage-htl.html" />
</carnivol:trim-white-space>

 

 And finally a more detailed log:

 

02.09.2020 09:54:53.381 *ERROR* [0:0:0:0:0:0:0:1 [1599033293378] GET /content/costo/master_website/it_IT.html HTTP/1.1] com.day.cq.wcm.core.impl.WCMDeveloperModeFilter Error during include of SlingRequestPathInfo: path='/content/costo/master_website/it_IT/jcr:content', selectorString='null', extension='html', suffix='null'
org.apache.sling.api.scripting.ScriptEvaluationException: org.apache.sling.scripting.jsp.jasper.JasperException: /apps/carnivol/framework/components/page/basepage/basepage.jsp(3,0) Unable to load tag handler class "com.carnivol.framework.utils.RemoveWhiteSpaceTag" for tag "carnivol:trim-white-space"
at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:416) [org.apache.sling.scripting.core:2.0.56]
at org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:184) [org.apache.sling.scripting.core:2.0.56]
at org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:491) [org.apache.sling.scripting.core:2.0.56]
at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:552) [org.apache.sling.engine:2.6.20]
at org.apache.sling.engine.impl.filter.SlingComponentFilterChain.render(SlingComponentFilterChain.java:44) [org.apache.sling.engine:2.6.20]
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:82) [org.apache.sling.engine:2.6.20]
at com.day.cq.wcm.core.impl.WCMDeveloperModeFilter.doFilterWithErrorHandling(WCMDeveloperModeFilter.java:164) [com.day.cq.wcm.cq-wcm-core:5.12.118]
at com.day.cq.wcm.core.impl.WCMDeveloperModeFilter.doFilter(WCMDeveloperModeFilter.java:135) [com.day.cq.wcm.cq-wcm-core:5.12.118]
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:72) [org.apache.sling.engine:2.6.20]
at com.day.cq.wcm.core.impl.WCMDebugFilter.doFilterWithErrorHandling(WCMDebugFilter.java:192) [com.day.cq.wcm.cq-wcm-core:5.12.118]
at com.day.cq.wcm.core.impl.WCMDebugFilter.doFilter(WCMDebugFilter.java:159) [com.day.cq.wcm.cq-wcm-core:5.12.118]
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:72) [org.apache.sling.engine:2.6.20]
at org.apache.sling.dynamicinclude.IncludeTagFilter.doFilter(IncludeTagFilter.java:71) [org.apache.sling.dynamic-include:3.0.0]
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:72) [org.apache.sling.engine:2.6.20]
at com.day.cq.wcm.core.impl.WCMComponentFilter.doFilter(WCMComponentFilter.java:278) [com.day.cq.wcm.cq-wcm-core:5.12.118]
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:72) [org.apache.sling.engine:2.6.20]
at com.day.cq.wcm.core.impl.page.PageLockFilter.doFilter(PageLockFilter.java:91) [com.day.cq.wcm.cq-wcm-core:5.12.118]
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:72) [org.apache.sling.engine:2.6.20]
at com.day.cq.personalization.impl.TargetComponentFilter.doFilter(TargetComponentFilter.java:94) [com.day.cq.cq-personalization:5.12.38]
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:72) [org.apache.sling.engine:2.6.20]
at com.adobe.granite.csrf.impl.CSRFFilter.doFilter(CSRFFilter.java:217) [com.adobe.granite.csrf:1.0.20.CQ650-B0002]
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:72) [org.apache.sling.engine:2.6.20]
at org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:282) [org.apache.sling.engine:2.6.20]
at org.apache.sling.engine.impl.SlingRequestProcessorImpl.dispatchRequest(SlingRequestProcessorImpl.java:322) [org.apache.sling.engine:2.6.20]
at org.apache.sling.engine.impl.request.SlingRequestDispatcher.dispatch(SlingRequestDispatcher.java:211) [org.apache.sling.engine:2.6.20]
at org.apache.sling.engine.impl.request.SlingRequestDispatcher.include(SlingRequestDispatcher.java:104) [org.apache.sling.engine:2.6.20]
at com.day.cq.wcm.core.impl.WCMComponentFilter$ForwardRequestDispatcher.include(WCMComponentFilter.java:516) [com.day.cq.wcm.cq-wcm-core:5.12.118]
at org.apache.jsp.libs.cq.Page.Page_jsp._jspService(Page_jsp.java:117)
...

 

Could anyone please suggest a solution? Thank you in advance.

JasperException jsp error migrate to AEM 6.5 Unable to load tag handler class

Accepted Solutions (1)

Accepted Solutions (1)

fcasamento

03-09-2020

Spoiler
Thanks @Vijayalakshmi_S, I found out that the problem was the uber jar version. In fact, switching from version 6.5.5 to 6.5.0, everything works magically well.

Answers (1)

Answers (1)

Vijayalakshmi_S

MVP

02-09-2020

Hi @fcasamento,

Can you check if your tag handler class is in "Exported Packages" section of your project bundle in OSGI console.

If it is not there, try adding it explicitly in maven-bundle-plugin/bnd-maven-plugin configuration.