spring-bootjspspring-webflowtldclassnotfound

Class Specified in Method signature of TLD function is not found - JasperException


I am migrating a project from legacy spring to springboot. Project uses Spring Webflow and plan to keep the configurations intact for webflow and port the project to springboot by updating the project structure and adding necessary boot libraries.

Currently stuck with a jasperexception from the embedded tomcat jasper libraries complaining that the class used in the method signature of TLD for a function is not found.

org.apache.jasper.JasperException: The class [javax.servlet.http.HttpServletRequest request] specified in the method signature in TLD for the function [mytld:getAppLink] cannot be found. [javax.servlet.http.HttpServletRequest request] at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:55) ~[tomcat-embed-jasper-9.0.36.jar!/:9.0.36] at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:294) ~[tomcat-embed-jasper-9.0.36.jar!/:9.0.36] at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:81) ~[tomcat-embed-jasper-9.0.36.jar!/:9.0.36]

If I update the function in TLD to a no argument function, it works fine at that point. But moment I have a class to pass in the constructor this error is thrown.

JSP:

<%@ include file="/WEB-INF/jsp/includes/includes.jspf" %>
<%@ taglib prefix="mytld" uri="MyTldLibrary" %>
<div id="header" class="style-header">
    <div id="headm">
        <a href="${mytld:getAppLink(pageContext.request)}" class="logos"></a>
        
    </div>
</div>

Here is snippet of my tld:

<?xml version="1.0" encoding="UTF-8" ?>

<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 web-jsptaglibrary_2_2.xsd"
    version="2.0">

    <tlib-version>2.2</tlib-version>
    <jsp-version>3.0</jsp-version>
    <short-name>mytld</short-name>
    <uri>MyTldLibrary</uri>
    <description>App EL Functions</description>
    
    <function>
        <name>getAppLink</name>
        <function-class>
            com.app.web.tags.AppWebFunctions
        </function-class>
        <function-signature>
            java.lang.String getAppLink(javax.servlet.http.HttpServletRequest request)
        </function-signature>
    </function>
</taglib>

Here is snippet of function getAppLink from AppWebFunctions class:

/**
     * Gets the App link.
     *
     * @param request the request
     * @return the App link
     * @throws UnsupportedEncodingException the unsupported encoding exception
     */
    public static final String getAppLink(final HttpServletRequest request) throws UnsupportedEncodingException {
        //LOGIC to retrieve applink
        return appLink;
    }

Solution

  • If I update the function in TLD to a no argument function, it works fine at that point. But moment I have a class to pass in the constructor this error is thrown.

    That's because <function-signature> does not include any parameter names, only the fully-qualified class name of the parameter's type can be specified.

    So, just remove the request parameter name and the TLD should work then.

    <function-signature>
        java.lang.String getAppLink(javax.servlet.http.HttpServletRequest)
    </function-signature>