I would check to make sure that your web server is allowing POST requests on your IPN handler URL. In this example, I used the PHP version of the example on the page you linked, and placed the script at /ipn.php
.
I then telnet to my server. (replace with your server address)
$ telnet myserver.com 80
Trying myserver.com...
Connected to myserver.com.
Escape character is '^]'.
Paste the following into your telnet session. (replace ipn.php and myserver.com). Add a blank line after the last command.
POST /ipn.php HTTP/1.1
Host: myserver.com
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 0
HTTP/1.1 200 OK
If you don't see a 200 Status, it means your application is not handling POST requests properly, which is a probable cause of the 405 Error.
You should make sure that you implement a doPost() method in your servlet, as well as a doGet().
If you are able to get the requests working from the IPN simulator, and are ready to move on to sandbox testing, make sure that you have the correct Notify URL and that IPN is enabled under the sandbox seller's profile.
Also, make sure that you IPN Handler is logging INVALID requests as well, so that you know if the request was even initiated.
Finally, make sure that the IPN verification URL is set to https://www.sandbox.paypal.com/cgi-bin/webscr
in your servlet. (the URL in the example you posted is https://www.paypal.com/cgi-bin/webscr
)