Tomcat7不会在ubuntu上启动(全新安装),权限被拒绝[关闭]
Posted
技术标签:
【中文标题】Tomcat7不会在ubuntu上启动(全新安装),权限被拒绝[关闭]【英文标题】:Tomcat7 won't start up on ubuntu (clean install), permission denied [closed] 【发布时间】:2014-11-01 08:40:06 【问题描述】:我有一个干净的 ubuntu 安装 (14) 并尝试运行 Tomcat7。我已经通过终端安装了它,运行应该启动 tomcat 的“sudo service tomcat7 start”命令,但是当我尝试打开时: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 (log),给出如下错误:
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.找到分步指南
【问题讨论】:
您是否已经尝试过查找 Tomcat 的startup.sh
并且在使用 shell 脚本启动 Tomcat 时遇到任何错误?
尝试命令“netstat -tuplen”并查看正在使用的端口列表以及进程 ID。查看哪个PID绑定了8080
【参考方案1】:
也许您在端口 8080 上运行了另一个服务,或者您的内核以某种方式关闭了该端口。尝试配置另一个端口,看看问题是否仍然存在。
编辑:好的,可操作的部分来了:打开终端并运行
netstat -t | grep 8080
这应该向您显示当前在端口 8080 上侦听的任何内容。由于 Ubuntu 没有立即激活防火墙,这很可能是问题的根源。
另一个编辑:原始问题并未说明您使用的是 Android。这是一条至关重要的信息,因为 Android 包含 SELinux,它禁止在未经安全层事先同意的情况下打开端口。要允许打开端口,请查看here。
【讨论】:
应该是评论 @lllogiq, "netstat -t | grep 8080"- 没有结果。之后,我将端口更改为 8077,并重新启动了 tomcat,但我得到了完全相同的错误。我是通过 VNC 连接到系统的,我已经在 Android 系统上部署了 ubuntu。反过来,昨天在清理安装之前,我运行 Apache2 没有问题。 @MDeSchaepmeester,你可能是对的。我添加了一个简单的命令来确定这是否确实是问题的根源。现在是答案还是我应该删除它并作为评论重新发布? @lllogiq 让我们拭目以待,看看 OP 怎么说 @lllogiq - 有趣的建议。 SELinux 很可能是罪魁祸首。在此处查看有关故障排除的更多详细信息以及可能的修复方法:techrepublic.com/blog/linux-and-open-source/…。【参考方案2】:这里你只需要从 tomcat 管理器中更改端口号,因为某些应用程序可能已经在使用你提供的 8080 端口。
使用下面的方法...
How to change the port of Tomcat from 8080 to 80?
【讨论】:
以上是关于Tomcat7不会在ubuntu上启动(全新安装),权限被拒绝[关闭]的主要内容,如果未能解决你的问题,请参考以下文章
Tomcat7 绑定到端口 80 在 Ubuntu 14.04LTS 中失败
为什么RabbitMQ + Ubuntu 18.04(全新安装)在重启后松动所有用户/数据?