tomcate6+myEclipse10+win配置远程调试

     在javaWeb开发工作中有时候会遇到一些莫名其妙的问题,在开发环境中程序正常但是将项目发布后会出现这样或者那样的问题,在开发测试环境中又不能重现问题,这时候就需要用到tomcate的远程调试功能。tomcat远程调试用的是JVM的JPDA框架,而tomcat默认是不启用JPDA的,需要我们手动开启。

     一、开启tomcate远程调试的配置

              找到“E:\tomcat.60\bin”在面的startup.bat文件在文件末尾添加如下配置,

                     set JPDA_TRANSPORT=dt_socket
                    set JPDA_ADDRESS=8000
                    set JPDA_SUSPEND=y,

              然后将“call "%EXECUTABLE%" start %CMD_LINE_ARGS%”,

                 修改为 “call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%”。

     说明:            JPDA_ADDRESS:远程调试的端口;

            JPDA_TRANSPORT:jpda的启动方式,有两个值dt_shmem和dt_socket分别表示本机调试和远程调试;

             

    修改后startup.bat配置如下:

@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements.  See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License.  You may obtain a copy of the License at
rem
rem     http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

if "%OS%" == "Windows_NT" setlocal
rem ---------------------------------------------------------------------------
rem Start script for the CATALINA Server
rem
rem $Id: startup.bat 908749 2010-02-10 23:26:42Z markt $
rem ---------------------------------------------------------------------------

rem Guess CATALINA_HOME if not defined
set "CURRENT_DIR=%cd%"
if not "%CATALINA_HOME%" == "" goto gotHome
set "CATALINA_HOME=%CURRENT_DIR%"
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
cd ..
set "CATALINA_HOME=%cd%"
cd "%CURRENT_DIR%"
:gotHome
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
echo The CATALINA_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
goto end
:okHome

set "EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat"

rem Check that target executable exists
if exist "%EXECUTABLE%" goto okExec
echo Cannot find "%EXECUTABLE%"
echo This file is needed to run this program
goto end
:okExec

rem Get remaining unshifted command line arguments and save them in the
set CMD_LINE_ARGS=
:setArgs
if ""%1""=="""" goto doneSetArgs
set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
shift
goto setArgs
:doneSetArgs

set JPDA_TRANSPORT=dt_socket
set JPDA_ADDRESS=8000
set JPDA_SUSPEND=y

call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%

:end

 到这步tomcate的配置完成,运行startup.bat文件当,出现表示配置成功。

 
    

      二、配置好tomcate后,还需要配置myEclipse才能用到远程调试,Myeclipse配置如下图:

           1、选择菜单Run→Debug Configurations              2、添加一个远程调试项目


 点击debug就可以了。

猜你喜欢

转载自x125858805.iteye.com/blog/2147857