如何使用 Eclipse 调试 Web 应用程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14094284/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I debug Web Application with Eclipse?
提问by alfo888_ibg
I would like to debug web application of my university mate because I am developing android application that it will interact with the web application.
我想调试我的大学伙伴的 Web 应用程序,因为我正在开发它将与 Web 应用程序交互的 android 应用程序。
I am using "debug" perspective and with andorid or normal Java application I don't have problem.. but with the web application I can't debug .. I put breackpoints and "debug as web application" in debug perspective... but it doesn't work...
我正在使用“调试”视角,并且使用 andorid 或普通 Java 应用程序我没有问题..但它不起作用......
It's my console
这是我的控制台
Initializing App Engine server
初始化 App Engine 服务器
30-dic-2012 20.06.21 com.google.apphosting.utils.jetty.JettyLogger info
INFO: Logging to JettyLogger(null) via com.google.apphosting.utils.jetty.JettyLogger
30-dic-2012 20.06.33 com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
INFO: Successfully processed C:\Users\alfo888_ibg\workspace\TablePlus\war\WEB-INF/appengine-web.xml
30-dic-2012 20.06.34 com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml
INFO: Successfully processed C:\Users\alfo888_ibg\workspace\TablePlus\war\WEB-INF/web.xml
30-dic-2012 20.06.44 com.google.apphosting.utils.jetty.JettyLogger info
INFO: jetty-6.1.x
30-dic-2012 20.06.48 com.google.appengine.api.datastore.dev.LocalDatastoreService init
INFO: Local Datastore initialized:
Type: High Replication
Storage: C:\Users\alfo888_ibg\workspace\TablePlus\war\WEB-INF\appengine-generated\local_db.bin
30-dic-2012 20.06.49 com.google.appengine.api.datastore.dev.LocalDatastoreService load
INFO: Time to load datastore: 297 ms
30-dic-2012 20.06.53 com.google.apphosting.utils.jetty.JettyLogger info
INFO: Started [email protected]:8888
30-dic-2012 20.06.53 com.google.appengine.tools.development.DevAppServerImpl start
INFO: The server is running at localhost:8888
30-dic-2012 20.06.53 com.google.appengine.tools.development.DevAppServerImpl start
INFO: The admin console is running at localhost:8888/_ah/admin
回答by David
Altough I have not worked with appengine.
虽然我没有使用过 appengine。
To local debug a gwt application i do the following procedure
要本地调试 gwt 应用程序,我执行以下过程
- mvn gwt:debug (or use the IDE tools to start your application in debug mode)
- Right click on your project select Debug as -> Debug configurations...
- mvn gwt:debug(或使用 IDE 工具在调试模式下启动应用程序)
- 右键单击您的项目选择调试为-> 调试配置...
Create a new java remote webapplication as example:
创建一个新的 java 远程 web 应用程序作为示例:
now your breakpoints should be reached.
现在应该到达您的断点。
回答by Carl Karawani
The above solution looks good, but will also need to attach to the server from the debugger through a JPDA port (ex. on setting it up via runtime arguments on port 4000 below).
上面的解决方案看起来不错,但还需要通过 JPDA 端口从调试器连接到服务器(例如,通过下面端口 4000 上的运行时参数进行设置)。
For example.. before running your web application on Tomcat or Jetty, you need to set your java opts:
例如.. 在 Tomcat 或 Jetty 上运行您的 Web 应用程序之前,您需要设置您的 java opts:
If you run your web application via the console you can do something like:
如果您通过控制台运行您的 Web 应用程序,您可以执行以下操作:
set JAVA_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n"
If you are running your application on Tomcat then you can these instructions of the "Java" tab in your tomcat config. (see image below)
如果您在 Tomcat 上运行您的应用程序,那么您可以在 tomcat 配置中的“Java”选项卡中查看这些说明。(见下图)
Java options:
Java选项:
-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n
Then from the IDE you can run the debugger to debug the target VM on port 4000. (like in screenshot below)
然后在 IDE 中,您可以运行调试器来调试端口 4000 上的目标 VM。(如下面的屏幕截图所示)
This page shows you a little more in detail how to do it:
此页面向您展示了更详细的操作方法:
回答by agim
You should start the web application with the debug flag. In Tomcat you must set the flag jpda
and restart. In Jetty should be similar.
您应该使用调试标志启动 Web 应用程序。在 Tomcat 中,您必须设置标志jpda
并重新启动。在Jetty应该是类似的。
回答by H-H
The problem has been discussedat length, and the new version of appengine-maven-plugin1.7.5-SNAPSHOT has just been released and allows for setting arguments in order to remote debug the application.
该问题已被详细讨论,新版本的appengine-maven-plugin1.7.5-SNAPSHOT 刚刚发布,并允许设置参数以远程调试应用程序。
antony explains how to do that here