[英]How do i debug a web application running on jetty in eclipse?
never done web programming before. 从来没有做过网络编程。 Is there a way to set breakpoints, see variable values in eclipse?
有没有办法设置断点,在eclipse中查看变量值? The app i want to debug makes a Query string whcih i would like to easily extract.
我想调试的应用程序生成一个我想轻易提取的查询字符串。
Click External Tools Config, 单击“外部工具配置”,
Select program and click the new button top left. 选择程序,然后单击左上角的新按钮。 Set location to your maven binary working directory to local workspace and arguments to jetty:run
将maven二进制工作目录的位置设置为本地工作空间,并将参数设置为jetty:run
In the environment tab set the maven opts. 在环境选项卡中设置maven opts。 Notice socket address = 4000 and suspend=y
注意套接字地址= 4000和suspend = y
The go to debug configurations and add a new remote application. 转到调试配置并添加新的远程应用程序。 Add a project name and set the socket address.
添加项目名称并设置套接字地址。 Now run the External tool it should say:
现在运行它应该说的外部工具:
Listening for transport dt_socket at address: 4000 在地址:4000处侦听传输dt_socket
Then you can debug the remote app and add breakpoints etc. 然后你可以调试远程应用程序并添加断点等。
I would run the application with maven using the command: mvnDebug jetty:run
我将使用以下命令运行maven应用程序:
mvnDebug jetty:run
And setup a remote Java application using port 8000, in Eclipse IDE. 在Eclipse IDE中使用端口8000设置远程Java应用程序。
See the ' Setting up Maven 2.0.8+ ' section of: http://docs.codehaus.org/display/MAVENUSER/Dealing+with+Eclipse-based+IDE 请参阅“ 设置Maven 2.0.8+ ”部分: http : //docs.codehaus.org/display/MAVENUSER/Dealing+with+Eclipse-based+IDE
None of the answers worked for me. 这些答案都不适合我。 Here's what did work:
这是做了什么工作:
-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n -Xdebug -Xnoagent -Djava.compiler = NONE -Xrunjdwp:transport = dt_socket,address = 8000,server = y,suspend = n
When you execute this runtime, the first thing the Eclipse console outputs (in blue) is: 当您执行此运行时时,Eclipse控制台输出的第一件事(蓝色)是:
Listening for transport dt_socket at address: 8000 在地址:8000处侦听传输dt_socket
Now you can create a Remote Java application Debug Runtime and connect to the debug port (8000 in this example) 现在您可以创建远程Java应用程序Debug Runtime并连接到调试端口(在此示例中为8000)
I would just expand eaykin's answer as the URL is broken. 由于URL被破坏,我只想扩展eaykin的答案。
Run the Mvn Debug as bellow... 运行Mvn Debug如下...
$ mvnDebug -Dmaven.test.skip -Denvironment=dev clean jetty:run $ mvnDebug -Dmaven.test.skip -Denvironment = dev clean jetty:run
This will wait on port 8000 这将在端口8000上等待
Preparing to Execute Maven in Debug Mode Listening for transport dt_socket at address: 8000 准备在调试模式下执行Maven在地址:8000处侦听传输dt_socket
Then go to the Eclipse Run --> Debug Configurations --> Remote Java Applications Define Host as 'localhost' and port as 8000 if they are not default. 然后转到Eclipse Run - > Debug Configurations - > Remote Java Applications将Host定义为'localhost',如果它们不是默认值,则转到8000。
If you click on the "Debug" button, this will start the application from mvn. 如果单击“调试”按钮,这将从mvn启动应用程序。
"Trying to run it this way i get CreateProcess error=193, %1 is not a valid Win32 application." “试图以这种方式运行它我得到CreateProcess错误= 193,%1不是一个有效的Win32应用程序。”
On windows select mvn.bat instead of mvn.exe. 在Windows上选择mvn.bat而不是mvn.exe。
If by any chance you are using intellij. 如果您有任何机会使用intellij。 It is way easier.
这样更容易。 Make sure you have jetty plugin installed.
确保安装了jetty插件。 Then
然后
The answer for this post shows you the flags need to pass to the JVM for a remote debugger to attach. 这篇文章的答案显示了需要传递给JVM以便远程调试器附加的标志。
Remote debug Jetty (no mvn, no plugins) 远程调试Jetty(没有mvn,没有插件)
This is the page that explains remote debuggers for the JVM 这是解释JVM的远程调试器的页面
http://docs.oracle.com/javase/1.3/docs/tooldocs/solaris/jdb.html http://docs.oracle.com/javase/1.3/docs/tooldocs/solaris/jdb.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.