Issue
Problem: I have some code on the server side that generates a null pointer exception. Normally this causes an HTTP 500 error code and my default error page for that code gets called. For whatever reason the error is getting displayed to browsers as a 405 error, (Method Not Allowed).
UserNode userNode= UserGraph.getNode(adjacencyList.get(i)); // This list is empty
The cause for the null pointer I have solved but why is Apache Tomcat masking this as a 405 and not a 500 exception?
Question: Are there any common reasons why a null pointer exception would cause a HTTP 405 error?
Solution
This behavior could happen if you have an error handling servlet that only implements doGet() and the exception occurs in the doPost() method of another servlet (or vice-versa).
Answered By - David Levesque
Answer Checked By - Gilberto Lyons (JavaFixing Admin)