简体   繁体   中英

Confused about behavior of NetBeans debugger while debugging a web app

I am working on a java ee web application in NetBeans. I am trying to debug the behavior of the application but the behavior I'm seeing is confusing.

I am running the application through NetBeans in Tomcat. Within NetBeans, I select "Debug" from the root of the Project Tree and I can send one request to the application I've written. Breakpoints are hit and I get unique results from the application.

However, every subsequent time I try to send a request to my application, I get the exact same incorrect result (even if I clear the cache on Chrome) and the Netbeans IDE doesn't stop at any of the defined breakpoints. Is this to be expected? Does a Servlet get mangled in memory once it runs through the debugger once? Do I need to stop and restart/reattach the NetBeans debugger every time I want to debug the application? Is there something I'm doing wrong when using the debugger? Does this indicate a problem with the code I've written in my Servlet?

Thanks,

Jason Mazzotta

rjsang's point on the cache might be valid, and is worth investigating. However, it might also be that something is breaking earlier than you expect, causing you to never even reach the break pointed lines.

I would suggest:

  1. Look into liberally sprinkling your code with debug logging statements (using a good logging framework such as Log4J with SLF4j)
  2. Throw more breakpoints at the problem - start with the very first line you expect to be hit from your request. And the go even higher/earlier, if possible.
  3. Tail that Tomcat log (catalina.out) - you might spot something catastrophic happening there.

Good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM