aspose file tools*
The moose likes Servlets and the fly likes Servlet code causes webserver to crash - sometimes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet code causes webserver to crash - sometimes" Watch "Servlet code causes webserver to crash - sometimes" New topic
Author

Servlet code causes webserver to crash - sometimes

Darren Briaris
Greenhorn

Joined: Jul 19, 2006
Posts: 15
I am not sure where to put this post but have chosen here as the code is within a servlet. The following problem is intermittent:-

  • When I am running Websphere in run mode, the browser gets a 'page cannot be displayed error'
  • When running in debug with no breakpoints, the browser gets the same message but the server stops itself (with no errors in the log files)
  • Sometimes the code runs fine and I can step through in debug fine. Other times debug also fails when stepping over




  • I have a form that is submitted and goes into a servlet to be processed.

    It reaches a point where the following line is run:-



    at this point the browser gets a page can not be displayed message and my test websphere server stops. It does not reach the system out line in the following code:-



    There are no error messages on the server log.

    _UWDatasource is an object that is created in the init() of the servlet.

    I am struggling to find out what the problem may be... any help appreciated!
    Rahul Bhattacharjee
    Ranch Hand

    Joined: Nov 29, 2005
    Posts: 2308
    To my best of knowledge server designs are failsafe.Due to some exception in the servlet you might get a 503 error , but its very unlikely that the complete server would crash.

    If you are confident about the statement that is causing the problem , then I would suggest you to keep the statement within a try and catch (Throwable t) and then do a t.printStackTrace() , so that you will have an idea about what is happening , when it crashes.


    Rahul Bhattacharjee
    LinkedIn - Blog
    William Brogden
    Author and all-around good cowpoke
    Rancher

    Joined: Mar 22, 2000
    Posts: 12785
        
        5
    page can not be displayed message

    from a browser sounds like one of those accursed "friendly" error messages that is concealing the real cause. In MS Internet Exploder you can turn off "friendly" error messages from the internet options dialog.

    Bill
    Darren Briaris
    Greenhorn

    Joined: Jul 19, 2006
    Posts: 15
    Originally posted by Rahul Bhattacharjee:
    To my best of knowledge server designs are failsafe.Due to some exception in the servlet you might get a 503 error , but its very unlikely that the complete server would crash.

    If you are confident about the statement that is causing the problem , then I would suggest you to keep the statement within a try and catch (Throwable t) and then do a t.printStackTrace() , so that you will have an idea about what is happening , when it crashes.


    I have a try catch block around the statement and it does not get hit by the code. I changes this to add your try./catch statement and this does not get hit either.
    It seems that if I have a debug statement in the called method it seems to go into the code OK. Without this it just 'disappears' and the browser gets no response...
    Darren Briaris
    Greenhorn

    Joined: Jul 19, 2006
    Posts: 15
    Originally posted by William Brogden:

    from a browser sounds like one of those accursed "friendly" error messages that is concealing the real cause. In MS Internet Exploder you can turn off "friendly" error messages from the internet options dialog.

    Bill


    I have removed the 'friendly messages' on IE but still get a page not displayed. It appears to me the the thread on the server is juts 'dying' for no apparent reason. Nor error codes. no exceptions...

    The browsers request is thus lost and no response received from the server.
    Darren Briaris
    Greenhorn

    Joined: Jul 19, 2006
    Posts: 15
    Just a little bit more info... I seem to be able to reproduce the error constantly:-

    It occurs on the second time submitting information from the page. The first submit works OK but the subsequent submit fails.
    Darren Briaris
    Greenhorn

    Joined: Jul 19, 2006
    Posts: 15
    Clutching at straws a bit now. The problem I am having occurs, as stated previously, on the second submit. As part of the first submit the savePolicyHolderMotor() method is throwing a DiscusException (one of my own exceptions)in order to indicate an error code. Could this be causing the problem when the second submit tries to call the savePolicyHolderMotor() method?

    I have added another test method that just returns a string and called this immediately before the troublesome line and it runs with no problems but the savePolicyHolderMotor() line still drops out immediately afterwards (on the second run).

    Really getting confused by this now I have run the app off my local machine on a proper websphere server and get the same problem still , so it is not unique to my local setup.

    Thank sin advance for any help offered!
    vu lee
    Ranch Hand

    Joined: Apr 19, 2005
    Posts: 189
    You'll need to collect more data to detect what the issue is, where it occurs, and under what condition it occurs. The two previous posts suggested to put a try-cach block and disable friendly message.
    1. put a try -- catch(Throwable t) around the block where you invoke the save method.
    try{
    ...
    ...
    savedOK = _UWDataSource.savePolicyHolderMotor(phMotor);
    ...
    ...
    }catch(Throwable t){
    //collect data.
    }

    2. You could collect more data by writing a test program using HttpConnection to invoke the servlet and print client side error msg.

    3. Write a POJO test to detect whether savePolicyHolderMotor() alone does not cause any issues. In this test, just repeatedly calls savePolicyHolderMotor() a few times.

    Once you have collected all the data, post them so people could eyeball to see what happened.
    William Brogden
    Author and all-around good cowpoke
    Rancher

    Joined: Mar 22, 2000
    Posts: 12785
        
        5
    Going back to this statement:
    at this point the browser gets a page can not be displayed message and my test websphere server stops.


    Does that mean:
    1. The web server program just exits without any message.
    -or-
    2. The web server program goes off to neverland and stops responding to anything but still sits in memory.
    3. Some state not 1 or 2
    Darren Briaris
    Greenhorn

    Joined: Jul 19, 2006
    Posts: 15
    Originally posted by vu lee:
    You'll need to collect more data to detect what the issue is, where it occurs, and under what condition it occurs. The two previous posts suggested to put a try-cach block and disable friendly message.
    1. put a try -- catch(Throwable t) around the block where you invoke the save method.
    try{
    ...
    ...
    savedOK = _UWDataSource.savePolicyHolderMotor(phMotor);
    ...
    ...
    }catch(Throwable t){
    //collect data.
    }

    2. You could collect more data by writing a test program using HttpConnection to invoke the servlet and print client side error msg.

    3. Write a POJO test to detect whether savePolicyHolderMotor() alone does not cause any issues. In this test, just repeatedly calls savePolicyHolderMotor() a few times.

    Once you have collected all the data, post them so people could eyeball to see what happened.


    With regards to point 1, I have tried this and the catch block is not reached when the error occurs.

    The problem only seems to manifest itself when using Internet Explorer. Firefox seems to be OK.

    It also only seems to happen when a third party calendar javascript control is used on the page, rather than just typing a particular date in...

    It seems bizarre that this causes the problem I am seeing but I will bo some more investigation...

    Thanks again for everybodys help..
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Servlet code causes webserver to crash - sometimes