tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Len Popp" <len.p...@gmail.com>
Subject Re: servlet init error pages
Date Fri, 16 Nov 2007 21:16:39 GMT
Yes, your servlets are supposed to extend HttpServlet, not just
implement the Servlet interface. I don't know if that's related to
your problem.

I'd say the next thing to look for is an error in your custom error
page. That would cause the output you're seeing. Is your error page a
JSP file? Try replacing it with a very simple page. If your error page
is a servlet, well, you said there's only one servlet in your app, and
it crashes in init()...
-- 
Len

On 11/15/07, Adam Parker <tforcram@gmail.com> wrote:
> Thanks again for all the replies.  Now time for some more details.
>
> Our app is running as the ROOT application.  I removed everything else from
> ROOT and replaced it with our code.  There is only one servlet running in
> this app, so if it fails no other apps or servlets are running.
>
> Tomcat is definitely running as the logs are getting written to, and the
> error I get back has Apache Tomcat/5.5.9 in it (note I messed up the tomcat
> version previously, I think I said it was 5.5.17 before).  Also mistaken was
> the error code.  We send 503 from inside our servlet (when it is running)
> and so I got confused.  The actual error is 500.
>
> Here is the stack trace being output on the page:
>
> javax.servlet.ServletException
>         mypackge.MyServlet.init(MyServlet.java:75)
>         org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
>         org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
>         org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
>         org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
>         org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
>         org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
>         org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
>         java.lang.Thread.run(Thread.java:619)
>
>
>
> Also possibly noteworthy is that we don't extend anything for our servlet,
> we just implement the interface.  Could that cause anything like this?  Is
> the error page handling dependent on extending HttpServlet or something like
> it?
>
> Thanks again for all the input.
>
> -Adam Parker
>
> On Nov 14, 2007 5:25 PM, Len Popp <len.popp@gmail.com> wrote:
>
> > After some further messing about, I can't make custom error pages fail
> > by throwing any sort of exception from a servlet's init() method. Even
> > UnavailableException doesn't break the error page.
> >
> > The only time I lose my custom error pages is when the entire web app
> > is down, not just the one servlet.
> >
> > So that goes back to the basic question, what's failing? Is Tomcat
> > running? Is the web app running? Do your log files show any errors?
> > --
> > Len
> >
> > On Nov 14, 2007 11:24 AM, Len Popp <len.popp@gmail.com> wrote:
> > > HTTP error 503 is "service unavailable", which means the servlet or
> > > web app is not running. There's a specific exception,
> > > UnavailableException, that tells Tomcat to remove the servlet from
> > > service. Is your servlet throwing that exception?
> > >
> > > I've found that <error-page> doesn't work with error 503 when the
> > > entire web app is down, but I'm not sure what happens when just one
> > > servlet is unavailable. Maybe error 503 acts differently in this case
> > > too.
> > >
> > > To answer one of your questions, yes the error page location is
> > > relative to the root of the web app. Sorry, I don't have the other
> > > answers right now.
> > > --
> > > Len
> > >
> > >
> > > On Nov 14, 2007 12:37 AM, Adam Parker <tforcram@gmail.com> wrote:
> > > > Thanks for the reply, at least I know someone else has gotten it to
> > work at
> > > > this point.
> > > >
> > > > Sorry for the lack of information.  I am on a deadline and trying to
> > do too
> > > > many things at once.  I've included all the important things I can
> > think of
> > > > below.
> > > >
> > > > Tomcat Version: 5.5.17
> > > > Error type:  I am seeing a 503 http error code being returned, but I
> > want to
> > > > be able to catch exception classes rather than specific error codes.
> > > >
> > > > I have tried
> > > >
> > > > <error-page>
> > > >                <exception-type>java.lang.Throwable</exception-type>
> > > >                <location>/yourErrorPage.jsp</location>
> > > > </error-page>
> > > >
> > > > and
> > > >
> > > > <error-page>
> > > >                <error-code>503</exception-type>
> > > >                <location>/yourErrorPage.jsp</location>
> > > > </error-page>
> > > >
> > > > in both my application web.xml, and in the tomcat web.xml (with the
> > default
> > > > servlet) with no success.  I still get a generic tomcat error page
> > showing a
> > > > stack trace.
> > > >
> > > > How is the error-page location related to my app?  I assumed that the
> > root
> > > > of the location corresponded to the root of my app, but maybe I am
> > > > mistaken.  Would tomcat still use the default error page if it can't
> > find
> > > > the error page, or would it give me a different error?  Oh, and can
> > the
> > > > error pages be static html (mine are, perhaps that is the problem)?
> > > >
> > > > As for the application, the servlet init method sets up all the
> > servlet
> > > > dependencies through spring config.  When there is a problem with the
> > config
> > > > file an exception is thrown and I see the error page.
> > > >
> > > > Thanks for any help,
> > > > Adam Parker
> > > >
> > > >
> > > >
> > > >
> > > > On Nov 13, 2007 6:12 PM, Len Popp <len.popp@gmail.com> wrote:
> > > >
> > > > > I do get my custom error page when an error happens in a servlet
> > > > > init() method. But you didn't give many details about your problem,
> > so
> > > > > I can't say whether you should be seeing custom error pages on your
> > > > > system.
> > > > >
> > > > > First of all, you didn't say what version of Tomcat you're using.
If
> > > > > it's older than 5.5, it could act differently from what I've seen.
> > > > >
> > > > > Secondly, I'm assuming the "errors" you speak of are exceptions that
> > > > > are thrown by the init() method. Not HTTP error status codes. (You
> > > > > can't call response.sendError() in init().).
> > > > >
> > > > > Normally, the servlet's init() is called when the first HTTP request
> > > > > is received for that servlet, and if it throws an exception a custom
> > > > > error page will be displayed as usual.
> > > > >
> > > > > If the servlet has "load-on-startup" specified in web.xml, init()
is
> > > > > called when the server starts up, before there are any web requests
> > -
> > > > > so obviously it can't return an error page to anyone. But then
> > init()
> > > > > will be called *again* when a request is received for the servlet,
> > and
> > > > > you'll see your error page then.
> > > > >
> > > > > Two reasons why you might not see your custom error page:
> > > > > 1. Error in the custom error page.
> > > > > 2. Error in the <error-page> declaration. To define a custom
error
> > > > > page for all exceptions, do this in your application's web.xml:
> > > > >        <error-page>
> > > > >                <exception-type>java.lang.Throwable</exception-type>
> > > > >                <location>/yourErrorPage.jsp</location>
> > > > >        </error-page>
> > > > > --
> > > > > Len
> > > > >
> > > > > On Nov 13, 2007 6:19 PM, Adam Parker <tforcram@gmail.com> wrote:
> > > > > > I am trying to override tomcat error pages, and I have tried
> > various
> > > > > > combinations of the <error-pages> element in both the
global
> > web.xml,
> > > > > and my
> > > > > > application web.xml.  Nothing is working.
> > > > > >
> > > > > > After some research I believe the problem is that the error
I am
> > looking
> > > > > at
> > > > > > actually occurs in the servlet.init(config) call.  This call
> > doesn't
> > > > > seem to
> > > > > > happen in the normal request processing loop, and hence the
> > > > > <error-pages> is
> > > > > > never used and a generic tomcat error is returned.
> > > > > >
> > > > > > Is there anyway to override this error even when outside the
> > context of
> > > > > a
> > > > > > request/reply?
> > > > > >
> > > > > > Any info on how the error is returned without a request/reply
> > would be
> > > > > > greatly appreciated.
> > > > > >
> > > > > > -Adam Parker
> > > > > >
> > > > >
> > > > >
> > ---------------------------------------------------------------------
> > > > > To start a new topic, e-mail: users@tomcat.apache.org
> > > > > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > > > > For additional commands, e-mail: users-help@tomcat.apache.org
> > > > >
> > > > >
> > > >
> > >
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message