在Eclipse中无法启动tomcat作为外部工具 [英] Cannot start tomcat as an external tool within eclipse

查看:173
本文介绍了在Eclipse中无法启动tomcat作为外部工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经配置eclipse可以启动(用于调试:使用jpda),并将tomcat作为程序停止。我第一次从eclipse启动/关闭tomcat是成功的。
但是当我第二次尝试启动tomcat时,我会收到以下错误:

 本机方法中的FATAL错误: JDWP没有传输初始化,jvmtiError = AGENT_ERROR_TRANSPORT_INIT(197)
错误:传输错误202:绑定失败:地址已在使用
错误:JDWP传输dt_socket无法初始化,TRANSPORT_INIT(510)
JDWP退出错误AGENT_ERROR_TRANSPORT_INIT(197):没有传输初始化[../../../src/share/back/debugInit.c:690]

我认为端口从未关闭,当我从eclipse运行shutdown tomcat。如果我重新启动计算机,端口将被释放,我可以从eclipse再次启动tomcat。
但是每次我无法重新启动我的电脑让它工作..寻找一个不太激进的解决方案...



这是我如何配置我的日食运行tomcat作为程序。

 配置eclipse中的外部工具配置
catalina脚本指向我的catalina.bat Windows机器
在参数下:jpda运行
在环境选项卡中。
JPDA_ADDRESS作为名称,8000作为值
JPDA_TRANSPORT作为名称,dt_socket作为值
JAVA_OPTS作为名称和-server -XX: + UseParallelGC -Xmx768m -XX:MaxPermSize = 160m -Djava.awt.headless = true作为值


解决方案

我不知道Eclipse如何工作,但是在停止和启动Tomcat时,您似乎试图绑定在同一个JPDA端口上。当您启动Tomcat时,显然是很好的,但是当您尝试停止它时,由于该端口已被占用,因此无法进行停止。



有很多方法解决这个问题,这些是我个人使用的:



1)从外部开始/停止Tomcat。 tomcat / bin / catalina.sh jpda start tomcat / bin / catalina.sh stop 任何变化。可能Eclipse允许启动外部脚本?



2)从Eclipse开始/停止Tomcat作为一个简单的Java程序。这样,您甚至不需要进行远程调试,因为您的程序将像其他Java程序一样可调试。我的IntelliJ配置如下所示:


主类: org.apache.catalina.startup.Bootstrap br>



虚拟机参数: -ea -cp $ CLASSPATH:/ path / to / tomcat / bin / bootstrap .jar -Dcatalina.base =/ path / to / tomcat-Dcatalina.home =/ path / to / tomcat-Djava.io.tmpdir =/ path / to / tomcat / temp-noverify -Xmx400M - XX:MaxPermSize = 400M



程序参数: 开始



工作目录: / path / to / tomcat



然后,您可以通过简单地杀死Java进程来停止tomcat,或者使用 stop 创建一个类似的环境,作为程序参数,将优雅地关闭它。如果您看到 catalina.sh ,所有这些脚本都是准备所有这些参数,并以相同的方式启动Tomcat。


I have configured eclipse to be able to start(for debug: using jpda) and stop tomcat as a program. The first time when i start/shutdown tomcat from eclipse is successful. But the second time when i try to start tomcat i get the following error:

FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
ERROR: transport error 202: bind failed: Address already in use
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../../../src/share/back/debugInit.c:690]

i think the port is never closed when i run shutdown tomcat from eclipse. If i restart my computer, the ports are released and i can run start tomcat again from eclipse. But everytime i cannot restart my computer to get it to work.. looking for a less radical solution...

This is how i configured my eclipse to run tomcat as a program.

Configured the external tool configuration in eclipse 
catalina script points to catalina.bat on my Windows machine 
under arguments : jpda run
In the Environment tab.
 "JPDA_ADDRESS" as the name and "8000" as the value
 "JPDA_TRANSPORT" as the name and "dt_socket" as the value
 "JAVA_OPTS" as the name and -server -XX:+UseParallelGC -Xmx768m -XX:MaxPermSize=160m -Djava.awt.headless=true as the value

解决方案

I have no idea about how Eclipse works, but it looks like you are trying to bind on the same JPDA port both when stopping and starting Tomcat. When you start Tomcat, then it's obviously fine, but when you attempt to stop it - the stopping can not be done because the port is already taken.

There are many ways to solve this, and these are the ones I personally use:

1) Start/stop Tomcat externally. tomcat/bin/catalina.sh jpda start, tomcat/bin/catalina.sh stop works out of the box without any changes. Maybe Eclipse allows launching external scripts?

2) Start/stop Tomcat as a simple Java program from Eclipse. This way, you won't even need remote debugging as your program will be debuggable as any other Java program. My IntelliJ config looks like this:

Main Class: org.apache.catalina.startup.Bootstrap

VM parameters: -ea -cp $CLASSPATH:/path/to/tomcat/bin/bootstrap.jar -Dcatalina.base="/path/to/tomcat" -Dcatalina.home="/path/to/tomcat" -Djava.io.tmpdir="/path/to/tomcat/temp" -noverify -Xmx400M -XX:MaxPermSize=400M

Program parameters: start

Working directory: /path/to/tomcat

Then you can stop tomcat by simply killing the Java process or create a similar environment with stop as program parameter which will gracefully shut it down. If you look inside catalina.sh, all this script does is really to prepare all these parameters and launch the Tomcat in the same way.

这篇关于在Eclipse中无法启动tomcat作为外部工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆