tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Najeed Ahmed Khan" <>
Subject javax.el.ELContext.getFunctionMapper().resolveFunction() returns null always
Date Tue, 17 Feb 2009 21:33:11 GMT


I'm developing an application to parse EL expressions from a file and
evaluate them. I am using Java Unified EL for the same. The value
expressions are resolving fine however the  functions are not. I'm using
Tomcat 6.0.10 which is bundled with JBoss 4.2.3. I've posted this query
to the Tomcat user mailing list earlier but it is related to the Tomcat
source so I'm it posting here as I didn't receive any response from the
user forums.


The way I am evaluating the expression is:


final MethodExpression methodExpr =

exprFactory.createMethodExpression(jspContext.getELContext(), el,
expectedType, paramTypes);

Object result = methodExpr.invoke(jspContext.getELContext(), params);



However, the function is not being invoked and I get a stack trace like


2009-02-12 22:35:13,629 [http-] ERROR STDERR () -
javax.el.ELException: Function 'testtld:escapeJava' not found

2009-02-12 22:35:13,630 [http-] ERROR STDERR () -     at

2009-02-12 22:35:13,630 [http-] ERROR STDERR () -     at

2009-02-12 22:35:13,630 [http-] ERROR STDERR () -     at

2009-02-12 22:35:13,630 [http-] ERROR STDERR () -     at

2009-02-12 22:35:13,630 [http-] ERROR STDERR () -     at

2009-02-12 22:35:13,630 [http-] ERROR STDERR () -     at

2009-02-12 22:35:13,630 [http-] ERROR STDERR () -     at



The jsp page that I am using to obtain the ELContext has the taglib
directive to include that particular tld. If I invoke that JSP function
from a JSP page(using EL), it works fine. However, when I try to resolve
the function programmatically as above, I get the above error.



When I checked the Tomcat source code, I noticed in
org.apache.jasper.el.ELContextImpl :


private final static FunctionMapper NullFunctionMapper = new
FunctionMapper() {

        public Method resolveFunction(String prefix, String localName) {

            return null;





And a few lines below that,


private FunctionMapper functionMapper = NullFunctionMapper; // immutable


Although there is a 


    public void setFunctionMapper(FunctionMapper functionMapper) {

        this.functionMapper = functionMapper;




I am not sure whether that is invoked or how to have it invoked.


This could be the problem for me as the
ELContext.getFunctionMapper().resolveFunction(...) would return null and
I receive a message which corresponds to the Method object resolving to
null. From org.apache.el.lang.ExpressionBuilder.visit, the code
generating the exception:


Method m = fnMapper.resolveFunction(funcNode.getPrefix(), funcNode


if (m == null) {

        throw new ELException(MessageFactory.get(

               "error.fnMapper.method", funcNode.getOutputName()));




When I check the generated servlet for the jsp that contains the same
EL, I see:


static private org.apache.jasper.runtime.ProtectedFunctionMapper


static {

ttld:escapeJava", org.apache.commons.lang.StringEscapeUtils.class,
"escapeJava", new Class[] {java.lang.String.class});







But if I put the following test code within the same jsp in a scriptlet,
I see the exception above(javax.el.ELException: Function
'testtld:escapeJava' not found):



    JspApplicationContext jspAppCtx =

    ExpressionFactory exprFactory = jspAppCtx.getExpressionFactory();

    ELContext elCtx = pageContext.getELContext();

    Class[] klass = {String.class};

    String[] param = {"Test String"};

    MethodExpression methodExpr =

"${testtld:escapeJava('Test String')}", String.class, klass);

    String result = methodExpr.invoke(elCtx, param).toString();




I searched over the internet and did not come up with anything
related/conclusive that could point me towards a configuration or
programmatic step that I could've missed.


I'd appreciate it if you could give me some pointers as to what might be
the problem here and how to fix it. Also, I do not understand why the
org.apache.jasper.el package is being used for the ELContext and other
implementations instead of the org.apache.el package which has the newer









  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message