开发者

Why am I getting a JasperException PWC:6299 for a custom jsp EL function?

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.v20100708015开发者_StackOverflow中文版0.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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜