Results 1 to 19 of 19
  1. #1
    Join Date
    May 2009
    Posts
    99

    Question Site loads on Refresh - host claims no problems with server - what's the problem?

    Hello everyone,

    A little over a month ago I signed up for my first server, a VPS, with a hosting company. I've been learning how to configure and setup things.

    I'm a Java based programmer, so my webpages are JSP (Java Server Pages) that interact with Java Servlets. Therefore, I have Tomcat installed on my VPS.

    I've uploaded my pages and have begun testing things. But there's a problem I run into on occasion. Sometimes when I call up my homepage I get a blank page that says "Done" in the status bar of the browser. When I hit Refresh, the page displays as it should.

    I've contacted the host provider and explained things. They replied that they have called up my site on various operating systems and browsers and haven't had that problem. I had a family member use their computer at work, and they have occasionally run into the same problem, it just shows Done, then you hit Refresh and it shows.

    The hosting company is being as helpful as they possibly can be, considering that the problem isn't occurring on their own computers and they have no way to replicate the problem otherwise. Also, they said that my server is fine.

    I could really use some input and troubleshooting suggestions. Your help is most appreciated.

    Thank You

  2. #2
    Join Date
    Aug 2002
    Location
    Superior, CO, USA
    Posts
    635
    Are you able to look at the Tomcat logs? Additionally, when it says "Done" did you check the source of the page to verify that the server sent you nothing? I've seen that an error in Tomcat and/or on the page can send just part of the page but that nothing gets rendered. This, coupled with checking catalina.out or your host log might get you pointed in the right direction. If it is an intermittent problem I'd suspect a memory issue but until you get a hold of the logs it is tough to know for sure.

    Lastly, is this a public site that you can give the URL to? It might be helpful to have more eyes on it.

  3. #3
    Join Date
    May 2009
    Posts
    99
    I will check the Source next time it occurs.

    A memory issue...hmm. Well I can tell you that I've been monitoring my memory usage, and right now, after a restart of tomcat, its using 132.8 mb out of 288 mb. Is that a bit high?

    I checked the Catalina.out file, it did show a NullPointerException report for the index.jsp file around the time I accessed my site this morning. But then again, after I refresh the page, everything shows and that voids out the exception. I don't understand why the exception would occur in the first place.

    I can't share the website at this time, sorry! Its a family business idea, and we're not ready to go public yet. I'm in testing phase right now.

  4. #4
    Join Date
    Aug 2002
    Location
    Superior, CO, USA
    Posts
    635
    Quote Originally Posted by JavaDziner View Post
    A memory issue...hmm. Well I can tell you that I've been monitoring my memory usage, and right now, after a restart of tomcat, its using 132.8 mb out of 288 mb. Is that a bit high?
    That seems a bit high but it depends on what you're doing in your site. If you're using that much memory are you bumping up what the JVM is allowed to take? On a 32 bit JVM the default is only 64M. You can bump this up with the -Xmx option.


    Quote Originally Posted by JavaDziner View Post
    I checked the Catalina.out file, it did show a NullPointerException report for the index.jsp file around the time I accessed my site this morning.
    So perhaps this is a coding issue, not a host issue. I'd hang on to the NPE to determine why it occurred. Maybe you're getting a database timeout. Maybe you're allocating more memory than possible. But one way or another there is a reason for the NPE. I'd focus on that first and go from there.

  5. #5
    Join Date
    May 2009
    Posts
    99
    Quote Originally Posted by stdunbar View Post
    That seems a bit high but it depends on what you're doing in your site. If you're using that much memory are you bumping up what the JVM is allowed to take? On a 32 bit JVM the default is only 64M. You can bump this up with the -Xmx option.
    I haven't touched the JVM options/settings. I'm going to have to look into that now.

    Quote Originally Posted by stdunbar View Post
    So perhaps this is a coding issue, not a host issue. I'd hang on to the NPE to determine why it occurred. Maybe you're getting a database timeout.
    That sounds pretty logical actually. The location of images as well as attributes needed throughout the session are accessed and setup through a call to a servlet, which in turn is interacting with a mysql database. A database timeout would make sense in this case. I suppose it would also explain why this problem is intermittent.

    Can I ask, since your more experienced than I am...in addition to looking into my code, where else, server and tomcat wise, should I be looking? Are there any attributes in the server.xml or web.xml file that I should be looking at?

  6. #6
    Join Date
    Aug 2002
    Location
    Superior, CO, USA
    Posts
    635
    I don't know how much more experienced I am but I would strongly encourage you to become familiar with JConsole. It can show you what is going on in the JVM on your server. It won't help you debug why you're getting a NullPointerException but if there are any memory issues or other resource constraints it can help there.

    One caution - if you're running this against a remote JVM and you've got most ports firewalled off it won't work. You'll need to take a look at this article to get a single port to connect to through your firewall.

  7. #7
    Join Date
    May 2009
    Posts
    99

    Update - Site loads on Refresh - Problem still persisting - Need Help

    Hi again,

    I am still having this problem, with the site occasionally not loading on first attempt. I have looked into it further, as far as I possibly can really, and have also posted on the Sun Java forum for some additional help/suggestions. I've also done a lot of google searching with various keywords.

    At this point, its been determined that it is very unlikely that this problem is occurring because of a memory issue. I have monitored/tested memory usage, and its not the issue.

    Also, it is quite possible that the problem is related to session creation. Especially since I am using session attributes that are pertinent to the operation of my site.

    I'm still digging to find that one right answer to this problem.

    When I had first contacted the host provider about this issue, they were unable to help, only because they had said my server settings were fine, and that they weren't experiencing the problem themselves. In other words, they were unable to replicate the problem. But in their first response, I do recall them mentioning 'clearing the browser cache'. I must ask then, could this be related to the problem I'm having? Because most notably, when I access a site page on 'a new day', it fails most often. If I'm able to, can I set any sort of parameters for the apache server to NOT cache my pages?

    Any input on this problem I'm having is greatly appreciated. This has been stumping me for weeks and weeks....

  8. #8
    If you dont mind could you provide us the sitename, so that we forum members can try it out from our end.

  9. #9
    Join Date
    Aug 2002
    Location
    Superior, CO, USA
    Posts
    635
    The default timeout for a Tomcat web app is 30 minutes. This default is defined in the $TOMCAT_HOME/conf/web.xml where $TOMCAT_HOME is where you have installed Tomcat. You can create your own session-config setting in your web application if 30 minutes is not appropriate.

    If your application behaves better after you've hit the page once then I would agree that it is a session issue. Caching may or may not be involved. But if you want to disable the browser from caching you can add some meta tags to your page:

    Code:
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="cache-control" content="no-store">
    <meta http-equiv="cache-control" content="private">
    <meta http-equiv="cache-control" content="max-age=0, must-revalidate">
    <meta http-equiv="expires" content="now-1">
    <meta http-equiv="pragma" content="no-cache">
    The problem is that different browsers handle these tags differently. I've used the above with success on everything I've tested on. These should go in the HEAD section of your HTML.

    Of course, the obvious question is why does caching break your web app. But this will let you test some more.

    Have you enabled the Tomcat Manager application? It is useful to have this as you can see what sessions exist and what is in each session.

  10. #10
    Join Date
    May 2009
    Posts
    99

    Question Update - An error providing more insight

    The Tomcat Manager, I do believe I have that enabled on the host, yes.

    Thank you for explaining and showing me how to set cache options! I appreciate that so much

    I have some good news, I think. I put an additional out.print into my servlet, specifically one in the catch to get info on exceptions that occur. Yes, I know, stupid of me not to have put that in sooner...

    When the page was requested the first time today, it showed this:

    ERROR :The last packet successfully received from the server was63030 milliseconds ago.
    The last packet sent successfully to the server was 63030 milliseconds ago, which is longer
    than the server configured value of 'wait_timeout'. You should consider either expiring and/or
    testing connection validity before use in your application, increasing the server configured values
    for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid
    this problem. and the cause :java.net.SocketException: Broken pipe


    I started looking into this. Here's what I can tell you that may help further solve this issue ---
    1) in the web.xml file for tomcat, I have session-timeout set to 30 mins.
    2) in the my.cnf file on the server, the [mysqld] section has this -
    [mysqld]
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    user=mysql
    # Default to using old password format for compatibility with mysql 3.x
    # clients (those using the mysqlclient10 compatibility package).
    old_passwords=1
    max_connections=100

    3)in the server.xml file, under my Resource declaration for connecting to the database, I have the following set -
    maxActive="100" maxIdle="30" maxWait="10000"
    removeAbandoned="true" removeAbandonedTimeout="300"
    logAbandoned = "true"
    (the url declaration has autoReconnect=true)

    I'm sorry, at this time, I am unable to share the web address of the site, because we're not ready to make it publicly known.

    I checked the wait_timeout variable when I logged into my server via ssh. The value returned was something like 28800. The exception reported that it took 63030 (63 seconds) which exceeds the wait_timeout value.

    After doing some googling, it appears that I can set the wait_timeout value in the my.cnf file of my server, like this -
    [mysqld]
    wait_timeout=80000

    But I read this page from mysql.com - http://bugs.mysql.com/bug.php?id=37704
    And specifically at the end of the page, a user states the following -
    *****************
    I am developing a JAVA application that will run 24 hours a day and from time to time, it
    may experience 8 hours or more of in-activity. The application renews the connection once
    at the start of a new day.

    Question:
    Will the global "wait_timeout" apply to the connection? Or, will the session
    "wait_timeout"?

    Currently, every other day or two, the first query of the day results in a SQL error due
    to the "wait_timeout".
    *****************

    His problem is very similar to mine, my site fails on the first request of a new day. So will setting wait_timeout in the my.cnf file solve the problem? I know, I'm going to have to try it and find out.

    Any additional insight on this issue? Thanks so much thus far for everyone's help.

  11. #11
    Join Date
    Aug 2002
    Location
    Superior, CO, USA
    Posts
    635
    How are you managing connections to MySQL? I would strongly encourage you to move to using the built in Tomcat connection pooling mechanism. The Tomcat JNDI docs go into this quite well and it even includes an example for MySQL.

    The big advantage for you of connection pooling is that you don't need to manage the connections yourself. The pool can be configured to automatically close the connection after a period of time if it is unused.

    And as you move to enterprise programming connection pooling is a must. In general it is very expensive to make a connection to a database and the less you can do it the better. JNDI is a J2EE spec so your code will not have to change if you move to a different application server. Only the configuration of the JNDI connection will change.

  12. #12
    Join Date
    May 2009
    Posts
    99
    Yes, I use connection pooling for my connections.

  13. #13
    Join Date
    Aug 2002
    Location
    Superior, CO, USA
    Posts
    635
    Then I would make sure that the you have a validationQuery set and that testOnBorrow is true (the default). Take a look at the DBCP docs for more detail. It appears that your connection is being closed at the MySQL server and then given to your application to use even though it is dead.

  14. #14
    Join Date
    May 2009
    Posts
    99
    I've never heard of validationQuery before (I must be really out of date).
    I followed the link and I'm adding the testOnBorrow="true" and the validationQuery parameters to the server.xml under the Resource tag.

    Question - is this the correct syntax for the validationQuery?
    validationQuery = select 1

    I thought the value should be set to something more like -
    select columnName from tableName where columName="somevalue"

    or is that not permitted, or more importantly, unnecessary?

  15. #15
    Join Date
    Aug 2002
    Location
    Superior, CO, USA
    Posts
    635
    Whatever query you put in there you should try through a normal SQL interface like the mysql command line. If it works there it should work in the DBCP settings. Different database vendors work differently so verify it first.

  16. #16
    Join Date
    May 2009
    Posts
    99
    I tested 'select 1' and indeed it works, it just returns '1'.

    I contacted the host provider again today, and they said to use 'interactive_timeout' instead of 'wait_timeout'. I was notifying them of the change I had made to my.cnf, and how the wait_timeout value being changed in that file, wasn't being reflected when I checked in mysql via ssh.

    I took their suggestion, and the change hasn't taken effect. So I have to ask them about this again.

    Do you know whether or not there is another file (either of the same type or different type) that a server would look to and possibly override my.cnf? Or does the server have to be restarted for the changes to take effect?

  17. #17
    Join Date
    Aug 2002
    Location
    Superior, CO, USA
    Posts
    635
    I'm a bit out of my league on MySQL server admin but I would not think that there should need to be any changes to MySQL. All you're doing with the changes to DBCP is saying that you want to run a very simple query each time you get a connection. That shouldn't influence the server config, just your program. But, again, there may be some benefits to doing as your provider suggests in MySQL that I'm not aware of.

  18. #18
    Join Date
    May 2009
    Posts
    99
    The service provider got back to me about the interactive_timeout thing, mysql server needed to be restarted for the changes to take effect.

    I will wait and test a site page tomorrow, and see if it fails, then post an update. I hope that its fixed

  19. #19
    Join Date
    May 2009
    Posts
    99

    Smile Problem solved :)

    Looks to be that the problem is solved! I've been requesting a page on each new day, and so far, things haven't failed. I'm so very pleased with the results.

    I want to sincerely thank everyone who posted on this topic for their help and suggestions Thank you so much!

Similar Threads

  1. Replies: 4
    Last Post: 11-28-2005, 05:10 PM
  2. Web host claims that site is memory resources hog
    By hfguide in forum Web Hosting
    Replies: 33
    Last Post: 07-25-2005, 07:02 PM
  3. Server auto-refresh & filesystem problem?
    By zappp in forum Dedicated Server
    Replies: 3
    Last Post: 01-24-2003, 11:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •