开发者

How can I diagnose a Null pointer exception in Tomcat

I am developing a Java Servlet to run in Tomcat. I am currently testing it with an XAMPP package, including Tomcat 7, on a Windows XP machine (don't worry, I am not planning on using this in production). I am doing this because I need to keep a connection open so I can use Comet server-push communications (server-push this is a must-have requirement).

The servlet is running, and I have written a test client which shows that client and server are communicating perfectly. The client hits the server from across the Internet with an HTTP header which generates a BEGIN event in the servlet, and it then communicates in response to READ events.

Then, I try a "real" client, which for us is a proprietary device which I do not have complete control over. It is difficult to get much information about what it is doing, and even worse, other programmers may make changes to it in the future. At best, all I will be able to do is make recommendations about future changes.

The device makes the HTTP request with header, the server handles the BEGIN event, but then, when the device tries to continue the conversation, the connection is dropped and I get the following in my catalina log file:

Oct 12, 2011 5:59:00 PM org.apache.coyote.http11.Http11NioProcessor process SEVERE: Error processing 开发者_如何学JAVArequest java.lang.NullPointerException at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436) at org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcessor.java:317) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1544) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722)

I know it is difficult to diagnose with this limited information, and that is exactly my question. How can get more information about what is going on with Tomcat? Furthermore, is there anything I can do to protect/inform/aid future programmers of the device from making the same mistake (whatever that happens to be)? Apparently, the problem is SEVERE, so am I in danger of a hacker taking down my server by making the mistake on purpose?

Any prompt responses with any suggestions at all will earn my eternal gratitude.


Just to update - I have no idea why, but the problem went away when we removed all carriage returns and line feeds from the communications after the initial header.

Thanks for your help. StackOverflow rules!


Put in debugging logs. Then you'll know where it failed. Things like knowing how the request is different, and why that causes the dropped connection are important and can be found by logging everything the server is doing. Log4j is great because it lets you log anything you want, then turn it off instantly when you don't need it any more.

"SEVERE" means that your server can't just gloss over the error and continue with the program, it doesn't indicate how severe the security issue is, which may not exist.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜