Transport dt_socket 8787 already in use
Asked Answered
R

3

5

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

$ mvn jetty:run

on issuing this command the first line was

Listening for transport dt_socket at address: 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?

Edit 1

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

<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.

Randazzo answered 6/9, 2013 at 17:23 Comment(4)
is it possible that you have a previous instance of jetty already running that perhaps crashed?, as it is linux you can try kill -9 <pid>, and you can run ps aux | grep jetty to know the pidDieldrin
@Dieldrin I have to run a client and server on same machine, see edited question.Randazzo
then it looks like you're trying to start two server instances listening on the same port, if you are running a client it does not need to start listening into any port, instead it gets connected to the server on the defined port. Am I understanding your issue right?Dieldrin
@Dieldrin No, to my understanding it has something it do with Java VM. docs.oracle.com/javase/1.4.2/docs/guide/jpda/conninv.htmlRandazzo
R
9

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:

-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:

export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=512M"
Randazzo answered 9/9, 2013 at 16:46 Comment(1)
This is exactly what happened to me - someone sent me their MAVEN_OPTS export and I put it in my .bash_profile and then I couldn't start more than one mvn:jetty.Retouch
C
9

Enter the below command in terminal / command prompt

killall -9 java

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

Cinda answered 20/4, 2016 at 6:35 Comment(1)
Worked for me, perfect answer.Harmonious
M
0

Try this configuration inside jetty plugin

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

Or alternatively, run jetty from command line this way

mvn -Djetty.port=9090 jetty:run
Mol answered 6/9, 2013 at 17:30 Comment(8)
Interesting, it should work according to the docs - docs.codehaus.org/display/JETTY/Maven+Jetty+PluginMol
The pom.xml has already port 8084 configured of Jetty. Looks to me the problem is in "JDWP Transport dt_socket"Randazzo
And are you trying to remotely debug Jetty?If yes, how your command looks?Mol
Edited the question, see if I have been able explain the problem bette.Randazzo
Ok, so I guess you run two servers on the same port, so you should change port number of one of themMol
No, to my understanding it has something it do with Java VM. docs.oracle.com/javase/1.4.2/docs/guide/jpda/conninv.htmlRandazzo
And are you running tests on it?Because Jetty automatically starts in debug mode when running tests on it, so this could cause the conflictMol
let us continue this discussion in chatRandazzo

© 2022 - 2024 — McMap. All rights reserved.