Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        5年前关闭。
                                                                                            
                
        
我有一个完整的ubuntu安装(14),并尝试运行Tomcat7。我已经通过终端安装了它,运行“ sudo service tomcat7 start”命令,该命令应该会启动tomcat,但是当我尝试打开:localhost:8080时,欢迎索引页面未加载,并且出现404错误(找不到文件) 。 8080端口也未打开,这似乎是某种许可问题。



Netstat提供以下内容(请注意,在启动tomcat的情况下,没有监听8080)

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(日志),给出以下错误:

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"]




解决了:

8080端口未使用,为了确定,我什至尝试将其更改为8089。无论如何,还有别的东西。
我已经通过命令行删除了所有tomcat7,并手动重新安装。从Apache网站安装最新版本后,一切正常。

可以找到分步指南here.

最佳答案

也许您在端口8080上运行了另一个服务,或者内核以某种方式关闭了该端口。尝试配置另一个端口,看看问题是否仍然存在。

编辑:好的,这是可行的部分:打开终端并运行

netstat -t | grep 8080


这应该可以显示当前正在端口8080上监听的所有内容。由于Ubuntu并未立即激活防火墙,这很可能是问题的根源。

另一个编辑:原始问题并未说明您使用的是Android。这是至关重要的信息,因为Android包括SELinux,该SELinux禁止在未经安全层事先同意的情况下打开端口。要允许打开端口,请查看here

09-11 18:05