Bug 41824

Summary: Unable to use nested type in TLD
Product: Tomcat 5 Reporter: Renaud Waldura <renaud+apache>
Component: JasperAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal CC: brian
Priority: P2    
Version: 5.5.20   
Target Milestone: ---   
Hardware: Other   
OS: other   

Description Renaud Waldura 2007-03-12 10:40:25 UTC
I wish to pass instances of a nested type to a JSP tag. My nested type is 
edu.ucsf.library.ltdl2.history.SearchHistory.Item (static inner class).
I wrote my TLD like so:

<tag>		
 ...
 <attribute>
  <name>historyItem</name>
  <required>no</required>
  <rtexprvalue>true</rtexprvalue>
  <type>edu.ucsf.library.ltdl2.history.SearchHistory.Item</type>
 </attribute>
</tag>

Tomcat (Jasper) 5.5.20 then fails with:

org.apache.jasper.JasperException: /WEB-INF/jsp/history/view.jsp(88,14) Unknown 
attribute type (edu.ucsf.library.ltdl2.history.SearchHistory.Item) for 
attribute historyItem.
	at org.apache.jasper.compiler.DefaultErrorHandler.jspError
(DefaultErrorHandler.java:39)
	at org.apache.jasper.compiler.ErrorDispatcher.dispatch
(ErrorDispatcher.java:405)
	at org.apache.jasper.compiler.ErrorDispatcher.jspError
(ErrorDispatcher.java:234)
	at 
org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes
(Validator.java:946)
	at org.apache.jasper.compiler.Validator$ValidateVisitor.visit
(Validator.java:710)
	at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1441)
	at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
	at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
	at org.apache.jasper.compiler.Validator$ValidateVisitor.visit
(Validator.java:730)
	at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1441)
	at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
	at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
	at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
	at org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
	at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
	at org.apache.jasper.compiler.Validator.validate(Validator.java:1489)
	at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:166)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
	at org.apache.jasper.JspCompilationContext.compile
(JspCompilationContext.java:563)
	at org.apache.jasper.servlet.JspServletWrapper.service
(JspServletWrapper.java:305)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile
(JspServlet.java:314)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


If I use the name "edu.ucsf.library.ltdl2.history.SearchHistory$Item" instead, 
I get: 

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 88 in the jsp file: /WEB-INF/jsp/history/view.jsp
Generated servlet error:
The nested type edu.ucsf.library.ltdl2.history.SearchHistory$Item cannot be 
referenced using its binary name

An error occurred at line: 88 in the jsp file: /WEB-INF/jsp/history/view.jsp
Generated servlet error:
The nested type edu.ucsf.library.ltdl2.history.SearchHistory$Item cannot be 
referenced using its binary name

	at org.apache.jasper.compiler.DefaultErrorHandler.javacError
(DefaultErrorHandler.java:84)
	at org.apache.jasper.compiler.ErrorDispatcher.javacError
(ErrorDispatcher.java:328)
	at org.apache.jasper.compiler.JDTCompiler.generateClass
(JDTCompiler.java:414)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
	at org.apache.jasper.JspCompilationContext.compile
(JspCompilationContext.java:563)
	at org.apache.jasper.servlet.JspServletWrapper.service
(JspServletWrapper.java:305)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile
(JspServlet.java:314)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


This appears to be related to bug 35351, where the nested type is used in 
<jsp:useBean> constructs. Thanks for your help.
Comment 1 Brian Lenz 2007-06-04 11:34:57 UTC
I am also having this problem with simple tag handlers (as opposed to classic
tag handlers described here by Renaud).  I get the exact same behavior he
described when trying to use an inner class for the type attribute in our simple
tag handler attributes.  Any idea when this might be fixed?
Comment 2 Mark Thomas 2009-07-24 12:10:36 UTC
This has been fixed in trunk and proposed for 5.5.x and 6.0.x
Comment 3 Mark Thomas 2009-08-15 10:59:57 UTC
This has been fixed in 6.0.x and will be included in 6.0.21 onwards.
Comment 4 Mark Thomas 2009-08-15 11:37:59 UTC
This has been fixed in 5.5.x and will be included in 5.5.29 onwards.