Remote Debugging (3)
use Eclipse| a Web application
创建一个简单的web项目
AServlet.java
package cn.zno; import java.io.IOException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; public class AServlet extends HttpServlet {
private static final long serialVersionUID = 1L; public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.getWriter().append("Served at: ").append(request.getContextPath()); } }
AServlet.java
web.xml
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>AServlet</servlet-name>
<display-name>AServlet</display-name>
<description></description>
<servlet-class>cn.zno.AServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AServlet</servlet-name>
<url-pattern>/AServlet</url-pattern>
</servlet-mapping>
</web-app>
web.xml
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cn.zno</groupId>
<artifactId>za</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>za Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provider</scope>
</dependency> <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>za</finalName>
</build>
</project>
pom.xml
构建一个war
[INFO] Building war: F:\e\workspacetest\za\target\za.war
部署到远程tomcat并以debug模式启动
%CATALINA_HOME%/webapps/
webapps
│ host-manager
│ manager
│ ROOT
│ za.war
设置debug模式的参数(通过setenv.bat设置)
%CATALINA_HOME%/bin/ 下添加文件 setenv.bat 内容如下
set "JAVA_OPTS= -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=y %JAVA_OPTS%"
如下图:
该文件会自动被catalina.bat 执行
启动
F:\e\tomcat\apache-tomcat-7.0.70\bin>startup.bat
会出现挂起的tomcat
启动debugger
远程电脑tomcat会继续执行,将 za 部署,日志如下:
Sep 20, 2016 12:18:23 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/7.0.70
Sep 20, 2016 12:18:23 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Jun 15 2016 16:27:45 UTC
Sep 20, 2016 12:18:23 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 7.0.70.0
Sep 20, 2016 12:18:23 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Windows 7
Sep 20, 2016 12:18:23 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 6.1
Sep 20, 2016 12:18:23 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: amd64
Sep 20, 2016 12:18:23 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: F:\e\java\jdk1.8.0_101\jre
Sep 20, 2016 12:18:23 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.8.0_101-b13
Sep 20, 2016 12:18:23 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
Sep 20, 2016 12:18:23 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: F:\e\tomcat\apache-tomcat-7.0.70
Sep 20, 2016 12:18:23 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: F:\e\tomcat\apache-tomcat-7.0.70
Sep 20, 2016 12:18:23 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Xdebug
Sep 20, 2016 12:18:23 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=y
Sep 20, 2016 12:18:23 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
Sep 20, 2016 12:18:23 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.util.logging.config.file=F:\e\tomcat\apache-tomcat-7.0.70\conf\logging.properties
Sep 20, 2016 12:18:23 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
Sep 20, 2016 12:18:23 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=F:\e\tomcat\apache-tomcat-7.0.70\endorsed
Sep 20, 2016 12:18:23 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=F:\e\tomcat\apache-tomcat-7.0.70
Sep 20, 2016 12:18:23 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=F:\e\tomcat\apache-tomcat-7.0.70
Sep 20, 2016 12:18:23 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.io.tmpdir=F:\e\tomcat\apache-tomcat-7.0.70\temp
Sep 20, 2016 12:18:23 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: F:\e\java\jdk1.8.0_101\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;F:\e\java\jdk1.8.0_101\bin;C:\Program Files\TortoiseSVN\bin;E:\apache-ant-1.9.6\bin;C:\Program Files\Git\cmd;F:\e\maven\apache-maven-3.2.5\bin;.
Sep 20, 2016 12:18:23 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Sep 20, 2016 12:18:23 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Sep 20, 2016 12:18:23 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 838 ms
Sep 20, 2016 12:18:23 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Sep 20, 2016 12:18:23 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.70
Sep 20, 2016 12:18:23 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive F:\e\tomcat\apache-tomcat-7.0.70\webapps\za.war
Sep 20, 2016 12:18:24 PM org.apache.catalina.loader.WebappClassLoaderBase validateJarFile
INFO: validateJarFile(F:\e\tomcat\apache-tomcat-7.0.70\webapps\za\WEB-INF\lib\servlet-api-2.5.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
Sep 20, 2016 12:18:24 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive F:\e\tomcat\apache-tomcat-7.0.70\webapps\za.war has finished in 551 ms
Sep 20, 2016 12:18:24 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory F:\e\tomcat\apache-tomcat-7.0.70\webapps\host-manager
Sep 20, 2016 12:18:24 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory F:\e\tomcat\apache-tomcat-7.0.70\webapps\host-manager has finished in 127 ms
Sep 20, 2016 12:18:24 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory F:\e\tomcat\apache-tomcat-7.0.70\webapps\manager
Sep 20, 2016 12:18:24 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory F:\e\tomcat\apache-tomcat-7.0.70\webapps\manager has finished in 92 ms
Sep 20, 2016 12:18:24 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory F:\e\tomcat\apache-tomcat-7.0.70\webapps\ROOT
Sep 20, 2016 12:18:24 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory F:\e\tomcat\apache-tomcat-7.0.70\webapps\ROOT has finished in 79 ms
Sep 20, 2016 12:18:24 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Sep 20, 2016 12:18:24 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Sep 20, 2016 12:18:24 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 977 ms
访问浏览器
http://localhost:8080/za/AServlet
即可进入到AServlet中的断点
浏览器页面加载中且进入到了Eclipse中的断点
继续执行后,浏览器显示结果
Remote Debugging (3)的更多相关文章
- 在chrome 总调试cordova出现Detached from the target. Remote debugging has been terminated with reason: Connection lost. Please re-attach to the new target
在chrome 总调试cordova出现如下错误: "Detached from the target. Remote debugging has been terminated with ...
- 转:Remote debugging with Visual Studio 2010
Original URL http://www.codeproject.com/Articles/146838/Remote-debugging-with-Visual-Studio-2010 you ...
- Remote Debugging (1)
The client/server design of the Java debugger allows you to launch a Java program from computer on y ...
- JPDA and Set up Tomcat for Remote Debugging
* About JPDA (http://docs.oracle.com/javase/7/docs/technotes/guides/jpda/architecture.html) JPDA: (J ...
- 安卓手机移动端Web开发调试之Chrome远程调试(Remote Debugging)
一.让安卓打debug模式的apk包 二.将电脑中的chrome升级到最新版本,在chrome浏览器地址栏中输入chrome://inspect/#devices: 在智能手机还未普及时,移动设备的调 ...
- Android WebView remote debugging
/***************************************************************************** * Android WebView rem ...
- Android/iOS Remote debugging
简单介绍 使用下面方法可以定位webview中的元素,无法定位view中的元素. 原文地址:http://mp.weixin.qq.com/s/y_UfdgjT_pkKgYivJmqt7Q webvi ...
- Remote Debugging Android Devices
Remote Debugging Android Devices //在电脑上远程调试安卓设备 By Kayce Basques Technical Writer at Google By Meggi ...
- 通过Chrome浏览器进行android调试/Remote Debugging on Android with Chrome
The way your web content behaves on mobile can be dramatically different from the desktop experience ...
- PyCharm 2017: Remote debugging using remote interpreter doesn't work
I set up a remote interpreter and verified that I can run a script using the remote interpreter. Con ...
随机推荐
- 转 移动端-webkit-user-select:none导致input/textarea输入框无法输入
移动端webview中写页面的时候发现个别Android机型会导致input.textareat输入框无法输入(键盘可以弹起,不是webView.requestFocus(View.FOCUS_DOW ...
- (转)wcf项目程序调试
由于使用分布式开发,因此在调试时,要分为客户端调试和服务端调试两种情况,下面就对这两种情况的调试步骤分别加以详细说明 调试客户端的页面代码 当仅仅需要调试客户端代码时,按照以下步骤进行操作: 1. ...
- poj 2528(线段树+离散化) 市长的海报
http://poj.org/problem?id=2528 题目大意是市长竞选要贴海报,给出墙的长度和依次张贴的海报的长度区间(参考题目给的图),问最后你能看见的海报有几张 就是有的先贴的海报可能会 ...
- Executors提供的四种线程池
Java 5+中的Executor接口定义一个执行线程的工具.它的子类型即线程池接口是ExecutorService.要配置一个线程池是比较复杂的,尤其是对于线程池的原理不是很清楚的情况下,因此在工具 ...
- guide dpdk
Welcome to DPDK Guide! Contents: Setting up DPDK Important Prerequisites Setting up repositories Red ...
- POJ1966 Cable TV Network
原题链接 割去点使得无向图不连通,和最小割相似. 我们可以将点转化成边,这样就能跑最小割了. 枚举每两个不能直接到达的点\(S,T\),使得删去一些点(除去这两个点)使得这两个点不连通(若两点能直接到 ...
- MySQL学习笔记-cache 与 buffer
Cache和Buffer是两个不同的概念,简单的说,Cache是加速"读",而 buffer是缓冲"写",前者解决读的问题,保存从磁盘上读出的数据,后者是解决写 ...
- Java时代即将来临
Java语言开发成型的时候有一个构想:就是智能设备互联,笔者推断这个时代即将来临. 我们看看信息时代经历的几个阶段: 机械设备阶段--以算盘.机械式计算机为代表的萌芽阶段. 电子管计算机阶段--以简单 ...
- Windows服务器支持json文件
Windows服务器默认是不支持json文件的直接读取的.如在浏览器中输入地址访问或是通过代码访问,都是无法获取到数据的.需要在服务器端进行配置,让服务器支持解析.json扩展名的json文件. 方法 ...
- 带token的get和post方法
GET和POST传值失败,多半是传输的字符串和URL的事 public static string ExcuteGetToken(string serviceUrl, string ReqInfo, ...