After a long long long downtime, I’ve finally managed to get my home brewed discussion board up and running again. My friend M shouted at me on the 23rd of August at 11:52 AM that it’s throwing some kind of NullPointerException, but I didn’t have time or motivation to investigate it before today. Actually I’ve been on my way to bed for several hours already, but I just couldn’t let it be.
The problem was that Java wasn’t able to create a Connection object. That was clear. The question was why. I started off by upgrading the MySQL JDBC driver and moving it to $CATALINA_HOME/shared/lib where the tomcat 5.5 docs say it should be. Didn’t help.
Then I changed my code from using a simple Class.forName() constuct to using connection pooling, defining a Resource in my web application’s context.xml and a resource-ref in the web.xml file. Although this modified the error messages a bit, it didn’t solve my problem.
However, the error message now said ‘Connection refused’, which got me into a whole other path of Googling. I found indications of that the MySQL driver wasn’t able to connect (DUUUH), but I couldn’t understand why, since a normal ‘mysql -p 3306 -uroot’ client connection did connect very well.
Now checking the listening services with ‘netstat -atn’ and grepping for 3306 (the default mysql port) gave me zip. I had found the problem: MySQL wasn’t even listening on the port it was supposed to listen on. No wonder the driver couldn’t connect.
Googling some more, I found some hints about disabling the ‘skip-networking’ option in mysql’s configuration. So I commented that out and instead restricted connections to only 127.0.0.1. After a restart of MySQL and another netstat-grep I found that it was finally listening to 3306, sweet.
When I now tested my application it was spinning as a Ferrari! There are still some bugs due to the MySQL upgrade, but that’s minor. At least it works now.