Tomcat failed to shutdown
Asked Answered
S

8

28

When I add the following Java options to enable debugging:

JAVA_OPTS="$JAVA_OPTS -noverify -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"

I get the following error whenever I try to shutdown the tomcat:

ERROR: transport error 202: bind failed: Address already in use ["transport.c",L41]
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510) ["debugInit.c",L500]
JDWP exit error JVMTI_ERROR_INTERNAL(113): No transports initializedFATAL ERROR in native method: JDWP No transports initialized, jvmtiError=JVMTI_ERROR_INTERNAL(113)
Spartacus answered 8/7, 2009 at 7:44 Comment(0)
G
36

Thank you for a nice short explanation, PHeath! Following your advice, I found the best way to solve the problem is simply to use CATALINA_OPTS instead of JAVA_OPTS.

Looking into catalina.sh, one can see CATALINA_OPTS is only used by the "start" and "start-security" commands, whereas JAVA_OPTS is also used by the "stop" command (at least with Tomcat 6.0.33 on openSUSE 12.1).

At least if you have Tomcat installed on Linux using a package manager then modifying the CATALINA_OPTS variable in /etc/tomcat6/tomcat6.conf (or whatever path in your distribution) is cleaner than changing the catalina.sh script directly, for the package manager assumes that the user changes only configuration files and breaking this assumption may cause problems when upgrading the Tomcat packages (e. g. lost settings because the catalina.sh file is overwritten).

I think one should prefer CATALINA_OPTS over JAVA_OPTS not only for JDWP but for many other options as well: e. g. if one uses the heap size option -Xmx... then it would be reasonable to put it into CATALINA_OPTS, as the "stop" command does not need much heap.

Grati answered 21/11, 2011 at 18:49 Comment(1)
What is your solution when using spring-boot(embedded tomcat)?Endothecium
E
30

You are trying to debug tomcat on startup, so it binds to port 5005 when the jvm starts.

When you run catalina.sh stop, it starts up another jvm which also tries to bind to port 5005.

You need to move the debug args to the run and start arguments (in catalina.sh) of tomcat, putting them straight into the JAVA_OPTS is the cause of the issue you're having.

Euonymus answered 24/9, 2009 at 14:56 Comment(0)
G
7

The problem is your tomcat is still running on the debug port(5005) or some other service running on the same port(5005).

If tomcat still running, you can kill it

  • if it in linux environment ps -ef|grep java, and identify the process id of it. and kill the process using sudo kill -9 .
  • If it in windows environment got to task manager and kill the tomcat and java process.

Now you should be able to start the server in debug mood without any prob.

This can happen on debugging unit test through the tool(eclipse) which has been executed through the maven. To sole this you can flow the same process.

First close the Eclipse and kill the java process as well and start it again.

Gaudery answered 16/4, 2014 at 10:11 Comment(0)
O
4

This is due to both applications are listening the same port number i.e 8000 while running in debug mode.

One quick solution is change the debug port to 8001 in startup.bat

SET DEBUGPORT=8001

Operatic answered 3/12, 2012 at 12:18 Comment(0)
T
2

It seems that the port 5005 is already in use. Check open ports with netstat command.

This may be because you already opened tomcat. Check your processes.

Tamarah answered 8/7, 2009 at 15:33 Comment(0)
S
1

It appears you are starting Tomcat with the Debugger enabled, This causes the JVM to attach to the Process for Debugging, However in the catalina.sh there is a case statement for start, stop, restart, so on and so forth. Issuing the stop command still adds this in as it is part of your Global JAVA_OPTS and tries to start the debugger listening on the same port for the shutdown command. If you remove the address=50005 from your JAVA_OPTS or use the start jdpa commands to start the VM with the debugger this will fix your problem.

Look at the default catalina.sh in the latest Tomcat distribution if you need a clean copy. It sounds like someone has made changes inside yours that are invalid and causing JDPA to run on start, stop, any command issued.

Spannew answered 19/11, 2009 at 1:56 Comment(0)
M
0

set JPDA_ADDRESS=8001 in catalina.bat i.e debug port and change all 3 ports in server.xml

Malversation answered 5/8, 2015 at 12:2 Comment(0)
S
0

In my case (Tomcat installed form tarball) I had those debug options unintentionally set in my env. This fixed the error:

$ unset JAVA_OPTS
Sitnik answered 14/12, 2021 at 17:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.