tags:

views:

21

answers:

2

I have a custom EL function defined as follows:

<function>
...
   <function-signature>
      java.lang.String getAsText(com.test.Outerclass.InnerEnum)
   </function-signature>
...
</function>

Here is what my class looks like:

package com.test;
public final class Outerclass {
   public enum InnerEnum {
      // ommited for clarity
   }
}

When I attempt to view the page I get the following exception:

org.apache.jasper.JasperException: PWC6299: The class com.test.Outerclass.InnerEnum specified in TLD for the function conversion:getAsText cannot be found: com.test.Outerclass.InnerEnum

My servlet container is Jetty (7.1.6.v20100715 distribution). This includes the following jars.

javax.servlet.jsp.jstl_1.2.0.v201004190952.jar
javax.servlet.jsp_2.1.0.v201004190952.jar
org.apache.taglibs.standard.glassfish_1.2.0.v201004190952.jar
javax.el_2.1.0.v201004190952.jar
org.apache.jasper.glassfish_2.1.0.v201007080150.jar

I found a related question here, however, the author accepted an answer which did not give any real indication on how the issue was resolved.

Edit:

For clarification, the class and enumeration are defined in a Google Protocol buffers message and the java code is generated by the protoc compiler. The resulting code cannot be changed.

+1  A: 

To have the com.test.Outerclass.InnerEnum identifier to work, the InnerEnum should be a nested enum, not an inner enum. I.e. add the modifier static to it.

package com.test;
public final class Outerclass {
   public static enum InnerEnum {
      // ommited for clarity
   }
}

Nested classes/enums can be constructed/used outside the outer class. Inner classes/enums can't, at least not directly without adding an extra layer of reflection logic. The average JSP EL implementation don't have that.

BalusC
I updated my question to reflect that I cannot modify the java class as it is generated by the protocol buffers compiler. I will however up vote this and keep it in my knowledge base as that is good to know.
predhme
A: 

I worked around the issue for now by using a string as the parameter instead of the enumeration itself. I then convert the string to the enumeration valueOf(String). Not what I really wanted but gets the job done.

predhme