org.apache.jasper.JasperException: The function test must be used with a prefix when a default namespace is not specified

org.apache.jasper.JasperException: The function test must be used with a prefix when a default namespace is not specified

This indicates that the environment doesn’t support the new EL 2.2 feature of invoking bean methods with arguments. The outdated environment is trying to interpret the expression as an EL function which has the notation namespace:functionName() (like as JSTL functions). The exception is merely complaining that namespace: part cannot be found in order to identify the EL function. But it is wrong, after all.

You need to ensure that the following conditions are met in order to be able to invoke bean methods with arguments in EL:

  1. The target container must support EL 2.2. All Servlet 3.0 compatible containers do, as EL 2.2 is part of Java EE 6 which in turn also covers Servlet 3.0. Examples of Servlet 3.0 containers are Tomcat 7.x, Glassfish 3.x and JBoss AS 6.x/7.x.

  2. The /WEB-INF/web.xml file is declared conform Servlet 3.0 specification (and thus not older, such as 2.5).

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app 
        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-app_3_0.xsd"
        version="3.0">
    
        <!-- Config here. -->
    
    </web-app>
    

    Otherwise your container will run in a fallback modus matching the version matching in web.xml root declaration, hereby losing all the new Servlet 3.0 and EL 2.2 awesomeness.

  3. The webapp’s /WEB-INF/lib does not contain container-specific EL implementation libraries originating from a container of an older make/version, such as el-api.jar and/or el-impl.jar originating from Tomcat 6.x or so.

Your concrete problem is caused by using a non-Servlet 3.0 compatible container: the old Glassfish 2.x.

Upgrade to Glassfish 3.x or look for alternate ways. The JBoss EL approach works only for JSF, not for Spring nor “plain JSP”.

Leave a Comment