tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phillip Morelock <subscripti...@phillipmorelock.com>
Subject Re: Unable to find setter: a problem with custom tag in TC 4.0.4b2
Date Sun, 02 Jun 2002 00:05:41 GMT
Are you just running the pet store example, cold or with your own edits?
how old is it?  You must be running tomcat 4, right?  maybe the example is
for 3, although in theory most stuff is backward compatible...

Also, it might help of course to see some jsp -- I assume you're already
doing everything "right" of course.  You didn't respond about what you found
under the /work directory for this.  What do you see there?  I am assuming
nothing.

fillup


On 6/1/02 1:46 AM, "Vernon Wu" <vernonw@gatewaytech.com> wrote:

> 
> Thanks very much, Philip for your quick response.
> 
> You are right. Theoretically, the numItems should be declaimed as a private
> but not protected attribute. I, however,
> don't think that is the cause, but why the TC keeps a blind eye on the setter
> method. The fragment of code is based on
> petstore 1.1.2 to have list of items. The commend, "setters (overloaded to fix
> bug in tomcat)", is made by the PetStore
> team. So I can assume there was a bug at the time. Now, the question whether
> the bug is still there.
> 
> I had have a look at the stack trace and can't find any cue of the problem at
> all.  Here is it:
> 
> 2002-05-30 04:20:25 ApplicationDispatcher[/mm] Servlet.service() for servlet
> jsp threw exception
> org.apache.jasper.compiler.CompileException:
> /jsp/fullsearchlist/content.jsp(4,0) Unable to find setter method for
> attribute: numItems
> at 
> org.apache.jasper.compiler.TagBeginGenerator.generateSetters(TagBeginGenerator
> .java:214)
> at 
> org.apache.jasper.compiler.TagBeginGenerator.generateServiceMethodStatements
> (TagBeginGenerator.java:332)
> at 
> org.apache.jasper.compiler.TagBeginGenerator.generate(TagBeginGenerator.java:3
> 94)
> at org.apache.jasper.compiler.JspParseEventListener$GeneratorWrapper.generate
> (JspParseEventListener.java:834)
> at 
> org.apache.jasper.compiler.JspParseEventListener.generateAll(JspParseEventList
> ener.java:241)
> at 
> org.apache.jasper.compiler.JspParseEventListener.endPageProcessing(JspParseEve
> ntListener.java:197)
> at org.apache.jasper.compiler.Compiler.compile(Compiler.java:215)
> at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:552)
> at 
> org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServ
> let.java:177)
> at 
> org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java
> :189)
> at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at 
> org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.ja
> va:683)
> at 
> org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher
> .java:574)
> at 
> org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.j
> ava:497)
> at 
> 
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:819>
)
> at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:391)
> at com.vernonwu.waf.view.template.Section.render(Section.java:41)
> at com.vernonwu.waf.view.template.tags.RenderTag.doEndTag(RenderTag.java:57)
> at org.apache.jsp.hscf$jsp._jspService(hscf$jsp.java:167)
> at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at 
> org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java
> :202)
> at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at 
> org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.ja
> va:683)
> at 
> org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher
> .java:574)
> at 
> org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.j
> ava:497)
> at 
> 
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:819>
)
> at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:391)
> at com.vernonwu.waf.view.template.Region.render(Region.java:35)
> at com.vernonwu.waf.view.template.tags.RenderTag.doEndTag(RenderTag.java:61)
> at org.apache.jsp.page$jsp._jspService(page$jsp.java:2198)
> at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at 
> org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java
> :202)
> at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at 
> org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.ja
> va:683)
> at 
> org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher
> .java:431)
> at 
> org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.j
> ava:355)
> at 
> com.vernonwu.waf.controller.web.action.HTMLActionRouter.route(HTMLActionRouter
> .java:44)
> at 
> com.vernonwu.waf.controller.web.ActionServlet.routeAction(ActionServlet.java:9
> 7)
> at 
> com.vernonwu.waf.controller.web.ActionServlet.service(ActionServlet.java:61)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at 
> org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.ja
> va:683)
> at 
> org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher
> .java:431)
> at 
> org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.j
> ava:355)
> at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:414)
> at 
> org.apache.jsp.validate_0002dfullsearch$jsp._jspService(validate_0002dfullsear
> ch$jsp.java:93)
> at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at 
> org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java
> :202)
> at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFi
> lterChain.java:247)
> at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChai
> n.java:193)
> at 
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java
> :243)
> at 
> 
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566>
)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at 
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java
> :190)
> at 
> 
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566>
)
> at 
> 
org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246>
)
> at 
> 
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564>
)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
> at 
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
> at 
> 
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566>
)
> at 
> org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.ja
> va:170)
> at 
> 
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564>
)
> at 
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
> at 
> 
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564>
)
> at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
> at 
> 
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564>
)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at 
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:1
> 74)
> at 
> 
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566>
)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at 
> org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:10
> 17)
> at 
> org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1115)
> at java.lang.Thread.run(Thread.java:536)
> 
> 
> 6/2/2002 7:08:08 AM, Phillip Morelock <subscriptions@phillipmorelock.com>
> wrote:
> 
>> I don't know if this is the desired answer, and don't have time to think
>> about the Java language issues here, but a quick fix would be to change:
>> 
>> protected int numItems = -1;
>> 
>> to
>> 
>> private int numItems = -1;
>> 
>> Then remove the overrides from Search and FullSearch classes.  Then ensure
>> that all access to the numItems variable occurs through getNumItems() and
>> setNumItems() in the base class, ListTag.
>> 
>> I have a feeling this has something to do with the fact that jsp:setProperty
>> can take two courses:
>> 1.  Set a public variable directly if it has the same name
>> 2.  Prepend "set" and adjust capitalization, as you seem to have
>> anticipated.
>> 
>> I would think, though, that option #1 would be excluded in this case because
>> the java compiler would refuse to compile your jsp if it thought you were
>> exactly trying to address a non-permitted variable (which the protected
>> variable shouldn't be permitted).
>> 
>> Can you send the stack trace of the exception?  Also, do you know that the
>> translated version of your page (the .java file it gets converted into) is
>> in the /work directory?  Check that out (_if_ tomcat got past the
>> translation phase, this is why you need to provide the stack trace) and you
>> can usually pinpoint your problem.
>> 
>> fillup
>> 
>> P.S.  Subclasses inherit all the public methods of all superclasses, so I
>> don't really understand your overrides.
>> 
>> On 5/29/02 8:04 PM, "Vernon Wu" <vernonw@gatewaytech.com> wrote:
>> 
>>> Hi, all,
>>> 
>>> I run into an error message on Tomcat 4.0.4b2 when I use a custom tag in a
>>> JSP
>>> file. The error message is:
>>> 
>>> /jsp/fullsearchlist/content.jsp(4,0) Unable to find setter method for
>>> attribute:   numItems
>>> 
>>> The code fragment is  the followings:
>>> 
>>> public abstract class ListTag extends TagSupport {
>>> // ...
>>> protected int numItems = -1;
>>> //...
>>> 
>>> // setters
>>> public void setNumItems(String numItemsStr) {
>>>   numItems = Integer.parseInt(numItemsStr);
>>> }
>>> }
>>> 
>>> public abstract class SearchListTag extends ListTag {
>>> //...
>>> // setters (overloaded to fix bug in tomcat)
>>> public void setNumItems(String numItemsStr) {
>>>   super.setNumItems(numItemsStr);
>>> }
>>> }
>>> 
>>> public class FullSearchListTag extends SearchListTag {
>>> //...
>>> public void setNumItems(String numItemsStr) {
>>>   super.setNumItems(numItemsStr);
>>> }
>>> }
>>> 
>>> I have tried to remove the setNumItems method from SearchList and/or
>>> FullSearchList, but can't resolute the problem.
>>> I
>>> learn that there was a bug led to this problem in the early version of
>>> Tomcat.
>>> Is   the bug unresolved yet? How I can
>>> overcome this problem?
>>> 
>>> Thanks very much in advance.
>>> 
>>> Vernon
>>> 
>>> 
>>> 
>>> --
>>> To unsubscribe, e-mail:
>>> <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
>>> For additional commands, e-mail:
>>> <mailto:tomcat-user-help@jakarta.apache.org>
>>> 
>> 
>> 
>> --
>> To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
>> For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>
>> 
>> 
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message