简体   繁体   English

在JVM中调试多线程Web服务器

[英]Debugging a Multithreaded Webserver in JVM

I'm developing a multithreaded webserver applet and have been dealing with system.out.println's for the past week or so as my "debugging" tool. 我正在开发一个多线程的Web服务器小程序,并在过去一周左右的时间内一直在处理system.out.println,作为我的“调试”工具。 As far as I understand it, the .jar I build is split by a builder and put into .html files and then spit out when I access the web server. 据我了解,我构建的.jar由构建器拆分并放入.html文件中,然后在访问Web服务器时吐出。

I am wondering if there is some way that I would be able to attach a debugger (plugin?) to Java's virtual machine that would allow me to step through the code as I operate the webserver- there are some critical exceptions that are very frustrating to track down. 我想知道是否可以通过某种方式将调试器(插件?)附加到Java的虚拟机上,从而使我可以在操作Web服务器时逐步执行代码-有些关键异常非常令人沮丧追查。 I believe they're timing issues related to the multithreading which makes them even more unreliable when attempting to locate, and may mean that the debugger won't process appropriately. 我认为它们是与多线程有关的计时问题,这使得它们在尝试定位时更加不可靠,并且可能意味着调试器将无法正确处理。 I don't think it matters, but the IDE I'm building in is Netbeans. 我认为这并不重要,但是我正在构建的IDE是Netbeans。

I've taken over a previous developer's hastily-not-quite-finished project and am in well over my head. 我已经接管了以前的开发人员匆忙完成的项目,现在我的想法已经过去了。 =/ Thanks in advance for any possible solutions, I appreciate it. = /在此先感谢您提供任何可能的解决方案,谢谢。

Sure you can. 你当然可以。

You need to start the web server JVM with suitable arguments allowing it to be debugged remotely. 您需要使用适当的参数启动Web服务器JVM,以允许对其进行远程调试。 You can see at http://download.oracle.com/javase/1.3/docs/tooldocs/win32/jdb.html how to do it. 您可以在http://download.oracle.com/javase/1.3/docs/tooldocs/win32/jdb.html上了解如何进行操作。 jdb is available in the JDK along with javac. jdb与javac一起在JDK中可用。 You then launch your IDE debugger to connect to your JVM and tell it where the source for your classes is located. 然后,您启动IDE调试器以连接到JVM, 告诉它您的类源位于何处。 Remember to compile with debug information. 请记住要使用调试信息进行编译。

As you have it inside Netbeans already then consider just launching it in debug mode as then all the extra work described above will be done automatically for you. 由于您已经在Netbeans中拥有它,因此可以考虑仅以调试模式启动它,因为上述所有其他工作将自动为您完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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