The Java Archive

javax.naming.NamingException: Could not create resource factory instance [Root exception is java.lang.ClassNotFoundException: org.apache.naming.factory.MailSessionFactory]

Sorry for the cryptic title, but on occasion I run across an issue like this, and fail to inform other programmers after finding the solution.

Tomcat 5.5.2x is missing the MailSessionFactory class in naming-factory.jar. This JAR can be found in [tomcat install]\common\lib. Delete (or rename) it, and then copy over the naming-factory.jar from the Tomcat 5.5.17 common\lib instead. Apparently, the SendMailFactory class was missing as well.

Click here to read the bug report.

Preventing the NullPointerException in Java

One of the most common exceptions in Java is the NullPointerException (NPE). Java beginners are often frustrated by this rather pestilent exception, since it offers little, if any help in determining the exact cause of a runtime failure. Unfortunately, most discussions that focus around the NPE devolve into the academics of pointers, and do little to rectify the situation. Instead of another such post, I thought I would offer up some friendly advice on preventing the NullPointerException altogether. Continue reading.