I have a clean ubuntu installation (14) and try to run Tomcat7. I have installed it via terminal, run the "sudo service tomcat7 start" command which should start tomcat, but when I try to open: localhost:8080, the welcome index page is not loading and I get a 404 error (file not found). The 8080 port is not opened either, it seem like some kind of permission problem.
Netstat gives the following (note there is not listening for 8080 with tomcat started)
android@localhost:~$ netstat -a | more
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:5900 *:* LISTEN
tcp 0 0 192.168.10.102:5900 94.102.51.229:26238 SYN_RECV
tcp 0 0 *:x11 *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 192.168.10.102:ssh 192.168.10.106:51076 ESTABLISHED
tcp6 0 0 [::]:ssh [::]:* LISTEN
tcp6 1 0 192.168.10.102:37029 bud02s01-in-f9.1e1:http CLOSE_WAIT
tcp6 0 0 192.168.10.102:33087 ea-in-f188.1e100.n:5228 ESTABLISHED
udp6 0 0 [::]:56456 [::]:*
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ACC ] STREAM LISTENING 2049 /dev/socket/vold
unix 2 [ ACC ] STREAM LISTENING 2062 /dev/socket/displayd
unix 2 [ ACC ] STREAM LISTENING 2064 /dev/socket/mdns
unix 2 [ ACC ] STREAM LISTENING 2066 /dev/socket/dnsproxyd
unix 2 [ ACC ] STREAM LISTENING 2068 /dev/socket/netd
unix 2 [ ] DGRAM 2462 /data/misc/wifi/sockets/wpa_c
trl_347-1
unix 2 [ ] DGRAM 2463 /data/misc/wifi/sockets/wpa_c
trl_347-2
unix 2 [ ACC ] STREAM LISTENING 2070 /dev/socket/rild-debug
unix 2 [ ACC ] STREAM LISTENING 109645 /var/run/dbus/system_bus_sock
et
unix 4 [ ] DGRAM 2496 /data/misc/wifi/sockets/p2p0
unix 2 [ ] DGRAM 3401 /data/misc/wifi/sockets/wpa_c
trl_347-3
Catalina.out (log), gives the following error:
Sep 08, 2014 9:52:46 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/common/classes], exists: [false], isDirectory: [false], canRead: [false]
Sep 08, 2014 9:52:46 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/common], exists: [false], isDirectory: [false], canRead: [false]
Sep 08, 2014 9:52:47 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/server/classes], exists: [false], isDirectory: [false], canRead: [false]
Sep 08, 2014 9:52:47 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/server], exists: [false], isDirectory: [false], canRead: [false]
Sep 08, 2014 9:52:47 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/shared/classes], exists: [false], isDirectory: [false], canRead: [false]
Sep 08, 2014 9:52:47 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/shared], exists: [false], isDirectory: [false], canRead: [false]
Sep 08, 2014 9:52:52 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Sep 08, 2014 9:52:52 AM org.apache.coyote.AbstractProtocol init
SEVERE: Failed to initialize end point associated with ProtocolHandler ["http-bio-8080"]
java.net.SocketException: Permission denied
at java.net.ServerSocket.createImpl(ServerSocket.java:308)
at java.net.ServerSocket.getImpl(ServerSocket.java:257)
at java.net.ServerSocket.bind(ServerSocket.java:376)
at java.net.ServerSocket.<init>(ServerSocket.java:237)
at java.net.ServerSocket.<init>(ServerSocket.java:181)
at org.apache.tomcat.util.net.DefaultServerSocketFactory.createSocket(DefaultServerSocketFactory.java:49)
at org.apache.tomcat.util.net.JIoEndpoint.bind(JIoEndpoint.java:397)
at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:640)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:434)
at org.apache.coyote.http11.AbstractHttp11JsseProtocol.init(AbstractHttp11JsseProtocol.java:119)
at org.apache.catalina.connector.Connector.initInternal(Connector.java:978)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:813)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.startup.Catalina.load(Catalina.java:638)
at org.apache.catalina.startup.Catalina.load(Catalina.java:663)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:280)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:454)
Sep 08, 2014 9:52:52 AM org.apache.catalina.core.StandardService initInternal
SEVERE: Failed to initialize connector [Connector[HTTP/1.1-8080]]
org.apache.catalina.LifecycleException: Failed to initialize component [Connector[HTTP/1.1-8080]]
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:106)
at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:813)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.startup.Catalina.load(Catalina.java:638)
at org.apache.catalina.startup.Catalina.load(Catalina.java:663)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:280)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:454)
Caused by: org.apache.catalina.LifecycleException: Protocol handler initialization failed
at org.apache.catalina.connector.Connector.initInternal(Connector.java:980)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
... 12 more
Caused by: java.net.SocketException: Permission denied
at java.net.ServerSocket.createImpl(ServerSocket.java:308)
at java.net.ServerSocket.getImpl(ServerSocket.java:257)
at java.net.ServerSocket.bind(ServerSocket.java:376)
at java.net.ServerSocket.<init>(ServerSocket.java:237)
at java.net.ServerSocket.<init>(ServerSocket.java:181)
at org.apache.tomcat.util.net.DefaultServerSocketFactory.createSocket(DefaultServerSocketFactory.java:49)
at org.apache.tomcat.util.net.JIoEndpoint.bind(JIoEndpoint.java:397)
at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:640)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:434)
at org.apache.coyote.http11.AbstractHttp11JsseProtocol.init(AbstractHttp11JsseProtocol.java:119)
at org.apache.catalina.connector.Connector.initInternal(Connector.java:978)
... 13 more
Sep 08, 2014 9:52:52 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 4826 ms
Sep 08, 2014 9:52:52 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Sep 08, 2014 9:52:52 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.52 (Ubuntu)
Sep 08, 2014 9:52:52 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /var/lib/tomcat7/webapps/ROOT
Sep 08, 2014 9:53:17 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 24972 ms
Sep 08, 2014 9:53:17 AM org.apache.catalina.core.StandardServer await
SEVERE: StandardServer.await: create[localhost:8005]:
java.net.SocketException: Permission denied
at java.net.ServerSocket.createImpl(ServerSocket.java:308)
at java.net.ServerSocket.getImpl(ServerSocket.java:257)
at java.net.ServerSocket.bind(ServerSocket.java:376)
at java.net.ServerSocket.<init>(ServerSocket.java:237)
at org.apache.catalina.core.StandardServer.await(StandardServer.java:426)
at org.apache.catalina.startup.Catalina.await(Catalina.java:777)
at org.apache.catalina.startup.Catalina.start(Catalina.java:723)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:321)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455)
Sep 08, 2014 9:53:17 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-8080"]
Sep 08, 2014 9:53:17 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Sep 08, 2014 9:53:17 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-8080"]
Sep 08, 2014 9:53:17 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-8080"]
Solved:
The 8080 port was not in use, I even tried to change it to 8089 to be sure. There was something other, anyway. I have removed all tomcat7 via command line, and reinstalled manually. After installing the latest version from the Apache website everything was ok.
Step by step guide can be found here.
Here you just have to change the port number from the tomcat manager because some applications may already using the port you given as 8080.
Use the following method...
How to change the port of Tomcat from 8080 to 80?
Perhaps you have another service running on port 8080, or your kernel somehow has that port closed. Try configuring another port and see if the problem persists.
Edit: Ok, here comes the actionable part: open a terminal and run
This should show you anything currently listening on port 8080. As Ubuntu doesn't activate a firewall out of the box, this is very likely the source of the problem.
Another edit: The original question did not state that you were on Android. This is a vital piece of information, as Android includes SELinux, which forbids opening a port without prior consent from the security layer. To allow opening the port, look here.