I recently signed up for a web host provider. My website pages are Java Server Pages.
My server runs with the following applications and versions.
Apache web server 2.2
Java 188.8.131.52 (SE 5)
I uploaded my site and began testing. I also configured what was necessary, per the instructional guides provided by the hosting company.
On occasion I have been getting a blank page, when accessing either the homepage or another page, at first attempt. If I request a page, and it returns blank, all I have to do is hit the Refresh key and everything loads. Each page after that loads as well.
What could the problem be? Your help is greatly appreciated. This problem concerns me very much.
Yes, I contacted the host about this. They told me that they are not experiencing this problem. They have tried accessing the site on various operating systems in various locations. The site loads every time. They are unable to replicate the problem.
The logs, yes I looked at the Tomcat log, and most notable was the NullPointerException. It was issued on an object who's value is set via an interaction between the JSP page and a Servlet. The servlet interacts with a database, retrieves a value from a table, and sets the value into the session.
So the code causing the NullPointer in the jsp page looks like this ;
The Servlet is retrieving a value from the database and setting that value into the session.
But a refresh loads the page and the site operates as it should. What could be the problem?
After adding some out.print's to my servlet, I got more precise information as to why this problem has been occurring.
The following error was revealed -
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
java.net.SocketException: Broken pipe
What fixed this issue in my case, was adding the following to the my.cnf file on my server, under [mysqld], and then having the mysql server restarted.
In addition, I added the following to the server.xml file under the Resource parameters for connecting to the database -
I'm so very pleased with the results, and wanted to post this update. Perhaps someone else having the same problem I did will find this information to be of help:)