Java 传输 dt_socket 8787 已在使用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18663278/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 09:57:53  来源:igfitidea点击:

Transport dt_socket 8787 already in use

javamavenjettymaven-jetty-plugin

提问by Gaurav Agarwal

I am trying to run a Server and Client application in Jetty server on my Ubuntu 12.04 machine. The server starts without any problem and I used the following command

我正在尝试在我的 Ubuntu 12.04 机器上的 Jetty 服务器中运行服务器和客户端应用程序。服务器启动没有任何问题,我使用了以下命令

$ mvn jetty:run

$ mvn码头:运行

on issuing this command the first line was

发出此命令时,第一行是

Listening for transport dt_socket at address: 8787

在地址侦听传输 dt_socket:8787

But when I launched the client I got the following error

但是当我启动客户端时出现以下错误

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]
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
Aborted

Looks something to do with transport dt_socket. I have no understanding what it is and how to use another address for Client?

看起来与传输 dt_socket 有关。我不明白它是什么以及如何为客户端使用另一个地址?

Edit 1

编辑 1

jetty-maven-plugin from pom.xml for client looks like this

来自 pom.xml 的 jetty-maven-plugin for client 看起来像这样

<build>
    <plugins>

      <!-- Specific jetty-maven-plugin configuration for running Jetty during
        development. None of its goals are run in a normal build lifecycle. -->
      <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>${jetty-maven-plugin.version}</version>
        <configuration>
          <webAppConfig>
            <contextPath>/</contextPath>
            <extraClasspath>${basedir}/src/test/resources/</extraClasspath>
          </webAppConfig>
          <connectors>
            <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
              <port>${servlet.port}</port>
              <host>0.0.0.0</host>
            </connector>
          </connectors>
          <reload>manual</reload>
          <useTestClasspath>true</useTestClasspath>
        </configuration>
      </plugin>
    </plugins>
  </build>

My assumption is some Jetty is starting in debug mode and trying to attach the debugger at port 8787 which is already bound to debugger of Server.

我的假设是某些 Jetty 正在以调试模式启动并尝试在端口 8787 上附加调试器,该端口已绑定到服务器的调试器。

采纳答案by Gaurav Agarwal

Jetty does NOT automatically starts the debugger. You most likely have set the MAVEN_OPTS environment variable to include -Xdebug parameters. Check with 'echo $MAVEN_OPTS' and you will see something like:

Jetty 不会自动启动调试器。您很可能已将 MAVEN_OPTS 环境变量设置为包含 -Xdebug 参数。检查'echo $MAVEN_OPTS',你会看到类似的东西:

-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n

You can't run two maven processes which both try to debug on port 8787. So change your global MAVEN_OPTS (in .bash_profile when running on osx) or change your MAVEN_OPTS for your second terminal session:

您不能运行两个都尝试在端口 8787 上调试的 maven 进程。因此,更改您的全局 MAVEN_OPTS(在 osx 上运行时在 .bash_profile 中)或更改您的第二个终端会话的 MAVEN_OPTS:

export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=512M"

回答by Petr Mensik

Try this configuration inside jetty plugin

在jetty插件中试试这个配置

<configuration>
    <connectors>
        <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
            <port>9090</port>
        </connector>
    </connectors>
</configuration>

Or alternatively, run jettyfrom command line this way

或者,以jetty这种方式从命令行运行

mvn -Djetty.port=9090 jetty:run

回答by Ashokchakravarthi Nagarajan

Enter the below command in terminal / command prompt

在终端/命令提示符中输入以下命令

killall -9 java

killall -9 java

It will kill all the java processes. You will be able to use the port then.

它会杀死所有的java进程。然后您将能够使用该端口。