tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Konstantin Novitsky" <>
Subject InvokerServlet wrapper exception handling...
Date Tue, 02 Apr 2002 20:50:32 GMT
I think I found a bug in

The current code in the 4.0.3 for some reason removes a wrapper
that it may not have allocated from the context on exception in
wrapper.allocate().(pls, see code/comments below for explanation).

Problem manifests itself, if you have a servlet (let's call it MyServlet)
that is
run via InvokerServlet (i.e. http://host/servlet/myServlet) and you want to
assign some init-params to MyServlet via web.xml. If MyServlet generates
an exception in its init() method it will be removed from the context and
of its parameters will be dropped as well. So if invoked again without
restarting the server, the wrapper will be recreated with and empty

I've tested a simple fix that removes suspect line:


It works. If my thinking is correct could someone tell me how
to get this change into a CVS tree.

Thanks, KN

public final class InvokerServlet
    extends HttpServlet implements ContainerServlet {
    public void serveRequest(HttpServletRequest request,
                             HttpServletResponse response)
        throws IOException, ServletException
        Wrapper wrapper = null;
        wrapper = (Wrapper) context.findChild(servletClass);
         if (wrapper != null) {
            // goes here if you put a <servlet> </servlet> section in the
            context.addServletMapping(pattern, wrapper.getName());
        } else {
            // creation of wrapper if doesn't exists
            wrapper = context.createWrapper();
            context.addServletMapping(pattern, name);

            instance = wrapper.allocate();
        } catch(ServletException e)
            context.removeServletMapping(pattern); // ok, paired with
addServletMapping above
            context.removeChild(wrapper); // PROBLEM! should not be called
if we did not created the wrapper.

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message