Search code examples
javanode.jstomcatports

Tomcat Server ports in use...what to do now


I found the message telling me that the ports required by Tomcat are already in use.

netstat -an|grep 8080
tcp6       0      0 :::8080                 :::*                    LISTEN     
netstat -an|grep 8005
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN 

So,I created the file tcp6.js using Node.js and bound it to 9000:

 var net=require('net');
 var chat=net.createServer();
 chat.on('connection',function(client){
    client.write('Die');
    client.end();
 });

 chat.listen(9000);

I logged out and logged back in. But the netstat still shows tcp6 bound to 8080 and 8005. These are the results of

ps aux | grep tomcat

tomcat7   2862  0.1  1.4 1960116 106080 ?      Sl   Mar19   1:46 /usr/lib/jvm/default-  
java/bin/java -Djava.util.logging.config.file=/var/lib/tomcat7/conf/logging.properties -  
Djava.awt.headless=true -Xmx128m -XX:+UseConcMarkSweepGC - 
Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -
Djava.endorsed.dirs=/usr/share/tomcat7/endorsed -classpath 
/usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar -
Dcatalina.base=/var/lib/tomcat7 -Dcatalina.home=/usr/share/tomcat7 -
Djava.io.tmpdir=/tmp/tomcat7-tomcat7-tmp org.apache.catalina.startup.Bootstrap start

anr      18444  0.0  0.0  13636   940 pts/2    S+   11:46   0:00 grep --colour=auto 
tomcat

Error printed in Eclipse Console:

org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/common/classes], exists: [false],  
isDirectory: [false], canRead: [false]
org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/common], exists: [false], 
isDirectory: [false], canRead: [false]
org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/server/classes], exists: [false],   
isDirectory: [false], canRead: [false]
org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/server], exists: [false], 
isDirectory: [false], canRead: [false]
org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/shared/classes], exists: [false], 
isDirectory: [false], canRead: [false]
org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/shared], exists: [false], 
isDirectory: [false], canRead: [false]
org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8180"] 
org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1678 ms
org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.35
org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8180"]
org.apache.catalina.startup.Catalina start
INFO: Server startup in 2199 ms

Solution

  • Go to tomcat home -> conf

    There is a file called server.xml, in that search for 8080 and replace it with 8180 and restart the tomcat.