-----------------------------
Please read the FAQ!
<http://java.apache.org/faq/>
-----------------------------
On Tue, 21 September 1999, "Craig R. McClanahan" wrote:
>
> -----------------------------
> Please read the FAQ!
> <http://java.apache.org/faq/>
> -----------------------------
>
> [EMAIL PROTECTED] wrote:
>
> > [snip]
>
> > Craig, you are right. Server is returning an error
> > because there is some intenal error within
> > JServ/servlet. This happens only with javascript.
> > No problem with HTML.
> >
>
> The first thing that would be useful is the text of the rest of the error message
>(i.e. the next few
> lines after the DOCTYPE line). That will tell you what error Apache is concerned
>about, although it
> sounds like it might be a generic "Error 500: Internal Server Error" from the sounds
>of the rest of the
> problem.
>
> >
> > I see the following error in JServ mod_jserv.log file :
> >
> > [21/09/1999 06:28:34:900] (EMERGENCY) ajp11: cannot scan servlet headers
> > [21/09/1999 06:28:34:900] (ERROR) an error returned handling request via protocol
>"ajpv11"
> >
>
> There are many possible causes for this, but the most likely is an unchecked
>exception (like a
> NullPointerException) in the servlet code, or Java code called by that servlet. You
>should also be
> seeing a stack traceback in the logs that tells you where the error actually
>occurred.
>
> >
> > When and why does this error occur ?
> > This might be too often asked error on this list. But,
> > I couldn't find relevant info in docs or faqs.
> >
> > My servlet code is as follows :
> >
> > import java.io.*;
> > import java.net.*;
> > import java.util.*;
> > import java.lang.reflect.*;
> >
> > import javax.servlet.*;
> > import javax.servlet.http.*;
> >
> > public class MyServlet extends HttpServlet {
> >
> > public String getServletInfo() {
> > return "MyServlet 1.0 by Ramesh";
> > }
> >
> > public void doGet(HttpServletRequest req, HttpServletResponse res)
> > throws IOException {
> >
> > MyServletBackend backend = new MyServletBackend();
> > backend.doGet(req, res);
> >
> > }
> > }
> >
>
> Well, it's unlikely that you got any exceptions out of this code itself -- but an
>exception that occurs
> inside the MyServletBackend class will cause exactly the same problems as an
>exception in the servlet
> itself. One way to help track it down would be to make sure you have JServ logging
>enabled, and then
> change your doGet method like this:
>
> public void doGet(HttpServletRequest req, HttpServletResponse res)
> throws IOException {
>
> MyServletBackend backend = null;
> try {
> backend = new MyServletBackend();
> backend.doGet(req, res);
> } catch (Exception e) {
> log(e, "MyBackend Threw An Exception!");
> }
>
> }
>
> This will log the error message and stack trace for the exception to the JServ log
>file. In addition,
> because the exception was swallowed by your servlet instead of being passed on to
>Apache JServ, you
> shouldn't trigger the Apache error. The output will either have nothing at all, or
>be partially
> completed, depending on how far in the error occurred.
>
> >
> > That's all is in the servlet. For simplicity, I put everything else in
>MyServletBackend to workaround
> > concurrency problems though there is a better way
> > using "sychronized"
> >
>
> Putting everything in the back end like this will actually perform better, if you
>can afford the memory
> space for the multiple MyBackend objects that might be created for simultaneous
>requests. However, if
> the MyBackend class uses shared resources internally in an unsafe manner, this does
>nothing by itself to
> take care of multithreading problems.
>
> >
> > If I use MyServletBackend directly, this error doesn't
> > come, however, I face multi threading issues.
> >
>
> Yep, that would be consistent with what we are seeing (if MyBackend throws an
>exception, you see an
> Apache error). The stack trace is a key tool in figuring out exactly where the
>problem occurred,
> although we obviously can't help you much with what is actually going wrong without
>the code.
>
>
> Craig McClanahan
Okay, after couple of more nights of head scratching
trial & error, I finally caught the sucker.
No, it wasn't an exception and there is absolutely
nothing in logs other than those two lines of
emergency error. No stack or nothing. That's what
made my life harder.
The problem is that I was setting the header field
"Last-modified" in response to the same value as
was given to me in "If-modified-since" field of the
request. "Last-modified" should be either absent
or more than "If-modified-since" field. Otherwise,
we should issue a "no change" status response.
If you haven't already faced this problem before,
better make a note of it.
Thanks to all of you who lead me to the summit.
Is there any detailed documentation on JServ where
one can find this kind of troubleshooting tips ?
thanks
Ramesh
--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]