Setting reloadable = true
is much the same as running a Rails app in test/dev mode, or a similar Django app under the web.py test server -- the server monitors your files for changes and reloads them as necessary so you don't have to restart the server. This is a feature that is intended only for development use.
As the above poster mentioned (and this is common of all these test platforms) there is quite a runtime performance price for this behavior -- your class files will be recompiled into bytecode with every minor change; and the overhead of monitoring the $CLASSPATH
for changes.
You should, ideally, have two environments, a dev environment where reloadable = true
is OK; and a production, code-controlled environment where performance and reliability are of the utmost importance.
The command netstat -nlp
will show you what is listening:
]# netstat -nlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN 13940/java
tcp 0 0 0.0.0.0:8009 0.0.0.0:* LISTEN 13940/java
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 13940/java
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3377/sshd
The lsof
command on the pid of the tomcat process will show something similar:
java 13940 root 35r CHR 1,9 942 /dev/urandom
java 13940 root 36r CHR 1,9 942 /dev/urandom
java 13940 root 38u IPv4 31050 TCP *:8009 (LISTEN)
java 13940 root 39u IPv4 31053 TCP 127.0.0.1:8005 (LISTEN)
When you run shutdown.sh
you should see traffic go to port 8005:
[root@test001 ~]# tcpdump -i lo 'port 8005'
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on lo, link-type EN10MB (Ethernet), capture size 96 bytes
20:11:22.168395 IP test001.36696 > test001.8005: S 2859727005:2859727005(0) win 32792 <mss 16396,sackOK,timestamp 20428874 0,nop,wscale 7>
20:11:22.168922 IP test001.8005 > test001.36696: S 2855491174:2855491174(0) ack 2859727006 win 32768 <mss 16396,sackOK,timestamp 20428874 20428874,nop,wscale 7>
20:11:22.168598 IP test001.36696 > test001.8005: . ack 1 win 257 <nop,nop,timestamp 20428874 20428874>
20:11:22.171127 IP test001.36696 > test001.8005: P 1:2(1) ack 1 win 257 <nop,nop,timestamp 20428877 20428874>
20:11:22.171144 IP test001.8005 > test001.36696: . ack 2 win 256 <nop,nop,timestamp 20428877 20428877>
20:11:22.171443 IP test001.36696 > test001.8005: P 2:3(1) ack 1 win 257 <nop,nop,timestamp 20428877 20428877>
20:11:22.171453 IP test001.8005 > test001.36696: . ack 3 win 256 <nop,nop,timestamp 20428877 20428877>
20:11:22.171686 IP test001.36696 > test001.8005: P 3:4(1) ack 1 win 257
- Check that
localhost
resolves e.g. it's in /etc/hosts.
- Check that you are not running the Ubuntu Firewall.
- Post your
netstat -nlp
output if you can.
- Try
telnet localhost 8005
or telnet 127.0.0.1
Best Answer
This problem appears to be because port-specific options (typically for debugging purposes) should be specified in CATALINA_OPTS instead of JAVA_OPTS. On shutdown, any port options in JAVA_OPTS will apply to the shutdown JVM, hence the "address already in use" error and shutdown failing. Please see https://stackoverflow.com/a/8216921/571357 - Jaan has provided a more complete answer.