AnsweredAssumed Answered

Processing tld function

Question asked by geoffberger on Oct 2, 2007
Latest reply on Oct 3, 2007 by kevinr
I have an issue with how Alfresco handles processing associated tlds in Linux (Ubuntu Feisty Fawn). Under Windows, there is no problem, but when under Linux, an exception is thrown indicating that is unable to evaluate a function specified in the tld. Moreover, the string that it complains about has the namespace perpended to it. I'm thinking that this is because somewhere Alfresco parses this String incorrectly, assuming Windows semantics. And so when it should be the name of the function it evaluates, it evaluates the namespace perpended to the function and throws an exception.

Below is the stacktrace:

Stacktrace:
   org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:467)
   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:371)
   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   org.apache.catalina.ssi.SSIFilter.doFilter(SSIFilter.java:125)
   org.alfresco.filter.CacheControlFilter.doFilter(CacheControlFilter.java:187)

root cause

javax.servlet.ServletException: javax.servlet.jsp.el.ELException: An error occurred while evaluating function "taglib:getLibTester"
   org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:842)
   org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
   org.apache.jsp.assets.includes.nav_jsp._jspService(nav_jsp.java:80)
   org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   org.apache.catalina.ssi.SSIFilter.doFilter(SSIFilter.java:125)
   org.alfresco.filter.CacheControlFilter.doFilter(CacheControlFilter.java:187)

root cause

java.lang.NullPointerException
   sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   java.lang.reflect.Method.invoke(Method.java:597)
   org.apache.commons.el.FunctionInvocation.evaluate(FunctionInvocation.java:172)
   org.apache.commons.el.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:263)
   org.apache.commons.el.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:190)
   org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:929)
   org.apache.jsp.assets.includes.nav_jsp._jspService(nav_jsp.java:71)
   org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   org.apache.catalina.ssi.SSIFilter.doFilter(SSIFilter.java:125)
   org.alfresco.filter.CacheControlFilter.doFilter(CacheControlFilter.java:187)

Below is the jsp, tld, and java. Keep in mind the example is very simple just to get things running.

jsp
<jsp:root version="1.2"
          xmlns:jsp="http://java.sun.com/JSP/Page"
     xmlns:c="http://java.sun.com/jsp/jstl/core"
     xmlns:taglib="http://www.alfresco.org/alfresco/taglib">

   <jsp:output doctype-root-element="html"
         doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
         doctype-system="http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'/>

   <jsp:directive.page language="java" contentType="text/html; charset=UTF-8"/>
   <jsp:directive.page isELIgnored="false"/>
   <c:out value="${taglib:getLibTester()}"/>

</jsp:root>

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_0.xsd"
        version="2.0">
   <tlib-version>1.0</tlib-version>
   <short-name>taglib</short-name>
   <uri>http://www.alfresco.org/alfresco/taglib</uri>
   <function>
      <name>getLibTester</name>
   <function-class>nav.LibTester</function-class>
   <function-signature>String getLibTester()</function-signature>
   </function>
</taglib>

java
package nav;

import java.util.*;
import java.text.*;

public class LibTester {
   public LibTester () {

   }

   public String getLibTester () {
      return "Testing the getLibTester method.";
   }
}

Geoff

Outcomes