You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Glenn Atter <ga...@oxmol.co.uk> on 2000/02/14 17:49:58 UTC

Re: Problems with TagBeginGenerator

Hi Folks,

For the past three months I have been developing a tag library for use
within tomcat. Unfortunately, when I tried the latest CVS version of tomcat
(obtained on 14 Feb 00) it breaks my tag library. I get the following error

Internal Servlet Error:

javax.servlet.ServletException: argument type mismatch
	at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:384)
	at
rs_00033.query._0005crs_00033_0005cquery_0005cqueryResult_0002ejspqueryResul
t_jsp_0._jspService(_0005crs_00033_0005cquery_0005cqueryResult_0002ejspquery
Result_jsp_0.java:1291)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
	at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
va:171)
	at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:258)
	at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:366)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
	at
org.apache.tomcat.core.ServletWrapper.handleInvocation(ServletWrapper.java:5
61)
	at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:341)
	at org.apache.tomcat.core.ContextManager.service(ContextManager.java:535)
	at
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection
(Ajp12ConnectionHandler.java:146)
	at org.apache.tomcat.service.TcpConnectionThread.run(TcpEndpoint.java:323)
	at java.lang.Thread.run(Thread.java:484)

Root cause:
org.apache.jasper.JasperException: argument type mismatch
	at
org.apache.jasper.runtime.JspRuntimeLibrary.handleSetProperty(JspRuntimeLibr
ary.java:484)
	at
rs_00033.query._0005crs_00033_0005cquery_0005cqueryResult_0002ejspqueryResul
t_jsp_0._jspService(_0005crs_00033_0005cquery_0005cqueryResult_0002ejspquery
Result_jsp_0.java:731)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
	at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
va:171)
	at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:258)
	at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:366)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
	at
org.apache.tomcat.core.ServletWrapper.handleInvocation(ServletWrapper.java:5
61)
	at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:341)
	at org.apache.tomcat.core.ContextManager.service(ContextManager.java:535)
	at
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection
(Ajp12ConnectionHandler.java:146)
	at org.apache.tomcat.service.TcpConnectionThread.run(TcpEndpoint.java:323)
	at java.lang.Thread.run(Thread.java:484)

I have tracked down the change that introduces this problem. It is to due to
how properties are been set in the latest version of TagBeginGenerator.java

i.e. the old version of (v 1.6) generated the following code

_jspx_th_rs3_for_0.setId("i");
_jspx_th_rs3_for_0.setStart(startRow);
_jspx_th_rs3_for_0.setEnd(endRow);

whilst the new version (v 1.7+) generates

JspRuntimeLibrary.introspecthelper(_jspx_th_rs3_for_1,"id","i",null,null,fal
se);
JspRuntimeLibrary.handleSetProperty(_jspx_th_rs3_for_1,"start",startRow);
JspRuntimeLibrary.handleSetProperty(_jspx_th_rs3_for_1,"end",endRow);

Now, the problem arises due to how this tag, a for tag, can be used. For
example the tag could be used in the following ways

<rs3:for id="i" start="1" end="3"></rs3:for>
<rs3:for id="i" start="<%=start%>" end="<%=end%>"></rs3:for>

The first example will set start to "1" whilst the second example will use
the variable start, in this case an int. To handle this difference in the
type of value there are a number of setter methods, each taking a different
type of value, i.e. String, int, Integer, etc. In the old version this
worked a treat and the for tag could be used in many different contexts.
However, by using JspRuntimeLibrary.handleSetProperty the new version does
not take account that there could be many different setter methods (based on
the type of value being used). So, JspRuntimeLibrary.handleSetProperty tries
to call the first setter method defined in the class file, in this case
setStart(String value), with an int value, resulting in an
IllegalArgumentException exception.

Any comments.

Glenn Atter


RE: Problems with TagBeginGenerator

Posted by Glenn Atter <ga...@oxmol.co.uk>.
Hi Mandar,

I agree with you that it boils down to whether a TagHandler
is a Java Bean or not. However, if it is bean, then should
the invocation be a little bit smarter.

That is to say, if there is a property named 'intvalue' and
it is an int then IMHO the system should allow the property
to be set via a string? i.e.

<tag:test intvalue="1"></tag:test>

Otherwise we have to use the tag in the following way

<tag:test intvalue="<%=1%>"></tag:test>

which is not intuitive to one of our end developer (someone
who is using our tags to develop a web-based application).

It would be nice if the system was a bit more forgiving. This
could be achieved by either using the old method of setting the
properties or by using the new method and automatically
converting the attributes to the appropriate type.

Thanks

Glenn

> -----Original Message-----
> From: Mandar.Raje@eng.sun.com [mailto:Mandar.Raje@eng.sun.com]On Behalf
> Of MANDAR RAJE
> Sent: 14 February 2000 17:43
> To: tomcat-dev@jakarta.apache.org
> Subject: Re: Problems with TagBeginGenerator
>
>
> Hi Glenn,
>
>  If my interpretation is correct then the question boils
> down to whether a TagHandler is a Java Bean or not.
>
>  If it is, then for a property named "start" which is an
> int, the method "setStart (int foo)" should be invoked. In this
> case the behavior of JspRuntimeLibrary seems to be correct.
>
>  If it is not, then you "may" have the extra flexibility of
> invoking "setStart (String foo)". In this case the behavior
> of RuntimeLibrary might be incorrect.
>
>  Any comments? If the behavior is incorrect then I don't mind
> rectifying it.
>
> Thanks,
> Mandar.
>
>
> Glenn Atter wrote:
> >
> > Hi Folks,
> >
> > For the past three months I have been developing a tag library for use
> > within tomcat. Unfortunately, when I tried the latest CVS
> version of tomcat
> > (obtained on 14 Feb 00) it breaks my tag library. I get the
> following error
> >
> > Internal Servlet Error:
> >
> > javax.servlet.ServletException: argument type mismatch
> >         at
> >
> org.apache.jasper.runtime.PageContextImpl.handlePageException(Page
> ContextImp
> > l.java:384)
> >         at
> >
> rs_00033.query._0005crs_00033_0005cquery_0005cqueryResult_0002ejsp
> queryResul
> >
> t_jsp_0._jspService(_0005crs_00033_0005cquery_0005cqueryResult_000
> 2ejspquery
> > Result_jsp_0.java:1291)
> >         at
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
> >         at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
> >         at
> >
> org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(Jsp
> Servlet.ja
> > va:171)
> >         at
> org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:258)
> >         at
> org.apache.jasper.runtime.JspServlet.service(JspServlet.java:366)
> >         at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
> >         at
> >
> org.apache.tomcat.core.ServletWrapper.handleInvocation(ServletWrap
> per.java:5
> > 61)
> >         at
> >
> org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper
> .java:341)
> >         at
> org.apache.tomcat.core.ContextManager.service(ContextManager.java:535)
> >         at
> >
> org.apache.tomcat.service.connector.Ajp12ConnectionHandler.process
> Connection
> > (Ajp12ConnectionHandler.java:146)
> >         at
> org.apache.tomcat.service.TcpConnectionThread.run(TcpEndpoint.java:323)
> >         at java.lang.Thread.run(Thread.java:484)
> >
> > Root cause:
> > org.apache.jasper.JasperException: argument type mismatch
> >         at
> >
> org.apache.jasper.runtime.JspRuntimeLibrary.handleSetProperty(JspR
> untimeLibr
> > ary.java:484)
> >         at
> >
> rs_00033.query._0005crs_00033_0005cquery_0005cqueryResult_0002ejsp
> queryResul
> >
> t_jsp_0._jspService(_0005crs_00033_0005cquery_0005cqueryResult_000
> 2ejspquery
> > Result_jsp_0.java:731)
> >         at
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
> >         at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
> >         at
> >
> org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(Jsp
> Servlet.ja
> > va:171)
> >         at
> org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:258)
> >         at
> org.apache.jasper.runtime.JspServlet.service(JspServlet.java:366)
> >         at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
> >         at
> >
> org.apache.tomcat.core.ServletWrapper.handleInvocation(ServletWrap
> per.java:5
> > 61)
> >         at
> >
> org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper
> .java:341)
> >         at
> org.apache.tomcat.core.ContextManager.service(ContextManager.java:535)
> >         at
> >
> org.apache.tomcat.service.connector.Ajp12ConnectionHandler.process
> Connection
> > (Ajp12ConnectionHandler.java:146)
> >         at
> org.apache.tomcat.service.TcpConnectionThread.run(TcpEndpoint.java:323)
> >         at java.lang.Thread.run(Thread.java:484)
> >
> > I have tracked down the change that introduces this problem. It
> is to due to
> > how properties are been set in the latest version of
> TagBeginGenerator.java
> >
> > i.e. the old version of (v 1.6) generated the following code
> >
> > _jspx_th_rs3_for_0.setId("i");
> > _jspx_th_rs3_for_0.setStart(startRow);
> > _jspx_th_rs3_for_0.setEnd(endRow);
> >
> > whilst the new version (v 1.7+) generates
> >
> >
> JspRuntimeLibrary.introspecthelper(_jspx_th_rs3_for_1,"id","i",nul
> l,null,fal
> > se);
> >
> JspRuntimeLibrary.handleSetProperty(_jspx_th_rs3_for_1,"start",startRow);
> > JspRuntimeLibrary.handleSetProperty(_jspx_th_rs3_for_1,"end",endRow);
> >
> > Now, the problem arises due to how this tag, a for tag, can be used. For
> > example the tag could be used in the following ways
> >
> > <rs3:for id="i" start="1" end="3"></rs3:for>
> > <rs3:for id="i" start="<%=start%>" end="<%=end%>"></rs3:for>
> >
> > The first example will set start to "1" whilst the second
> example will use
> > the variable start, in this case an int. To handle this
> difference in the
> > type of value there are a number of setter methods, each taking
> a different
> > type of value, i.e. String, int, Integer, etc. In the old version this
> > worked a treat and the for tag could be used in many different contexts.
> > However, by using JspRuntimeLibrary.handleSetProperty the new
> version does
> > not take account that there could be many different setter
> methods (based on
> > the type of value being used). So,
> JspRuntimeLibrary.handleSetProperty tries
> > to call the first setter method defined in the class file, in this case
> > setStart(String value), with an int value, resulting in an
> > IllegalArgumentException exception.
> >
> > Any comments.
> >
> > Glenn Atter
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
>


Re: Problems with TagBeginGenerator

Posted by MANDAR RAJE <ma...@pathfinder.eng.sun.com>.
Hi Glenn,

 If my interpretation is correct then the question boils
down to whether a TagHandler is a Java Bean or not.

 If it is, then for a property named "start" which is an 
int, the method "setStart (int foo)" should be invoked. In this
case the behavior of JspRuntimeLibrary seems to be correct.

 If it is not, then you "may" have the extra flexibility of 
invoking "setStart (String foo)". In this case the behavior
of RuntimeLibrary might be incorrect.

 Any comments? If the behavior is incorrect then I don't mind
rectifying it.

Thanks,
Mandar.


Glenn Atter wrote:
> 
> Hi Folks,
> 
> For the past three months I have been developing a tag library for use
> within tomcat. Unfortunately, when I tried the latest CVS version of tomcat
> (obtained on 14 Feb 00) it breaks my tag library. I get the following error
> 
> Internal Servlet Error:
> 
> javax.servlet.ServletException: argument type mismatch
>         at
> org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
> l.java:384)
>         at
> rs_00033.query._0005crs_00033_0005cquery_0005cqueryResult_0002ejspqueryResul
> t_jsp_0._jspService(_0005crs_00033_0005cquery_0005cqueryResult_0002ejspquery
> Result_jsp_0.java:1291)
>         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
>         at
> org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
> va:171)
>         at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:258)
>         at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:366)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
>         at
> org.apache.tomcat.core.ServletWrapper.handleInvocation(ServletWrapper.java:5
> 61)
>         at
> org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:341)
>         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:535)
>         at
> org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection
> (Ajp12ConnectionHandler.java:146)
>         at org.apache.tomcat.service.TcpConnectionThread.run(TcpEndpoint.java:323)
>         at java.lang.Thread.run(Thread.java:484)
> 
> Root cause:
> org.apache.jasper.JasperException: argument type mismatch
>         at
> org.apache.jasper.runtime.JspRuntimeLibrary.handleSetProperty(JspRuntimeLibr
> ary.java:484)
>         at
> rs_00033.query._0005crs_00033_0005cquery_0005cqueryResult_0002ejspqueryResul
> t_jsp_0._jspService(_0005crs_00033_0005cquery_0005cqueryResult_0002ejspquery
> Result_jsp_0.java:731)
>         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
>         at
> org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
> va:171)
>         at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:258)
>         at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:366)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
>         at
> org.apache.tomcat.core.ServletWrapper.handleInvocation(ServletWrapper.java:5
> 61)
>         at
> org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:341)
>         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:535)
>         at
> org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection
> (Ajp12ConnectionHandler.java:146)
>         at org.apache.tomcat.service.TcpConnectionThread.run(TcpEndpoint.java:323)
>         at java.lang.Thread.run(Thread.java:484)
> 
> I have tracked down the change that introduces this problem. It is to due to
> how properties are been set in the latest version of TagBeginGenerator.java
> 
> i.e. the old version of (v 1.6) generated the following code
> 
> _jspx_th_rs3_for_0.setId("i");
> _jspx_th_rs3_for_0.setStart(startRow);
> _jspx_th_rs3_for_0.setEnd(endRow);
> 
> whilst the new version (v 1.7+) generates
> 
> JspRuntimeLibrary.introspecthelper(_jspx_th_rs3_for_1,"id","i",null,null,fal
> se);
> JspRuntimeLibrary.handleSetProperty(_jspx_th_rs3_for_1,"start",startRow);
> JspRuntimeLibrary.handleSetProperty(_jspx_th_rs3_for_1,"end",endRow);
> 
> Now, the problem arises due to how this tag, a for tag, can be used. For
> example the tag could be used in the following ways
> 
> <rs3:for id="i" start="1" end="3"></rs3:for>
> <rs3:for id="i" start="<%=start%>" end="<%=end%>"></rs3:for>
> 
> The first example will set start to "1" whilst the second example will use
> the variable start, in this case an int. To handle this difference in the
> type of value there are a number of setter methods, each taking a different
> type of value, i.e. String, int, Integer, etc. In the old version this
> worked a treat and the for tag could be used in many different contexts.
> However, by using JspRuntimeLibrary.handleSetProperty the new version does
> not take account that there could be many different setter methods (based on
> the type of value being used). So, JspRuntimeLibrary.handleSetProperty tries
> to call the first setter method defined in the class file, in this case
> setStart(String value), with an int value, resulting in an
> IllegalArgumentException exception.
> 
> Any comments.
> 
> Glenn Atter
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org