Tomcat7不会在ubuntu上启动(clean install),权限被拒绝

时间:2021-10-26 16:50:52

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.

我有一个干净的ubuntu安装(14)并尝试运行Tomcat7。我已经通过终端安装了它,运行应该启动tomcat的“sudo服务tomcat7 start”命令,但是当我尝试打开:localhost:8080时,欢迎索引页没有加载,我得到一个404错误(文件没有找到)。8080端口也没有打开,这看起来像是某种权限问题。


Netstat gives the following (note there is not listening for 8080 with tomcat started)

Netstat给出以下内容(注意,没有监听已启动的tomcat 8080)

android@localhost:~$ netstat -a | moreActive 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    ESTABLISHEDtcp6       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 ESTABLISHEDudp6       0      0 [::]:56456              [::]:*                             Active UNIX domain sockets (servers and established)Proto RefCnt Flags       Type       State         I-Node   Pathunix  2      [ ACC ]     STREAM     LISTENING     2049     /dev/socket/voldunix  2      [ ACC ]     STREAM     LISTENING     2062     /dev/socket/displaydunix  2      [ ACC ]     STREAM     LISTENING     2064     /dev/socket/mdnsunix  2      [ ACC ]     STREAM     LISTENING     2066     /dev/socket/dnsproxydunix  2      [ ACC ]     STREAM     LISTENING     2068     /dev/socket/netdunix  2      [ ]         DGRAM                    2462     /data/misc/wifi/sockets/wpa_ctrl_347-1unix  2      [ ]         DGRAM                    2463     /data/misc/wifi/sockets/wpa_ctrl_347-2unix  2      [ ACC ]     STREAM     LISTENING     2070     /dev/socket/rild-debugunix  2      [ ACC ]     STREAM     LISTENING     109645   /var/run/dbus/system_bus_socketunix  4      [ ]         DGRAM                    2496     /data/misc/wifi/sockets/p2p0unix  2      [ ]         DGRAM                    3401     /data/misc/wifi/sockets/wpa_ctrl_347-3

Catalina.out (log), gives the following error:

卡特琳娜。输出(log),出现以下错误:

Sep 08, 2014 9:52:46 AM org.apache.catalina.startup.ClassLoaderFactory validateFileWARNING: 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 validateFileWARNING: 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 validateFileWARNING: 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 validateFileWARNING: 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 validateFileWARNING: 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 validateFileWARNING: Problem with directory [/usr/share/tomcat7/shared], exists: [false], isDirectory: [false], canRead: [false]Sep 08, 2014 9:52:52 AM org.apache.coyote.AbstractProtocol initINFO: Initializing ProtocolHandler ["http-bio-8080"]Sep 08, 2014 9:52:52 AM org.apache.coyote.AbstractProtocol initSEVERE: 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 initInternalSEVERE: 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 moreCaused 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 moreSep 08, 2014 9:52:52 AM org.apache.catalina.startup.Catalina loadINFO: Initialization processed in 4826 msSep 08, 2014 9:52:52 AM org.apache.catalina.core.StandardService startInternalINFO: Starting service CatalinaSep 08, 2014 9:52:52 AM org.apache.catalina.core.StandardEngine startInternalINFO: Starting Servlet Engine: Apache Tomcat/7.0.52 (Ubuntu)Sep 08, 2014 9:52:52 AM org.apache.catalina.startup.HostConfig deployDirectoryINFO: Deploying web application directory /var/lib/tomcat7/webapps/ROOTSep 08, 2014 9:53:17 AM org.apache.catalina.startup.Catalina startINFO: Server startup in 24972 msSep 08, 2014 9:53:17 AM org.apache.catalina.core.StandardServer awaitSEVERE: 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 pauseINFO: Pausing ProtocolHandler ["http-bio-8080"]Sep 08, 2014 9:53:17 AM org.apache.catalina.core.StandardService stopInternalINFO: Stopping service CatalinaSep 08, 2014 9:53:17 AM org.apache.coyote.AbstractProtocol stopINFO: Stopping ProtocolHandler ["http-bio-8080"]Sep 08, 2014 9:53:17 AM org.apache.coyote.AbstractProtocol destroyINFO: 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.

8080端口没有使用,我甚至想把它改成8089。反正还有别的事。我已经通过命令行删除了所有tomcat7,并手动重新安装。在从Apache网站安装最新版本之后,一切都很好。

Step by step guide can be found here.

步骤指南可以在这里找到。

2 个解决方案

#1


1  

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.

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

Edit: Ok, here comes the actionable part: open a terminal and run

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

netstat -t | grep 8080

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.

这将显示当前正在监听端口8080的任何内容。由于Ubuntu没有打开防火墙,这很可能是问题的根源。

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.

另一个编辑:最初的问题没有说明你在使用Android。这是一个重要的信息,因为Android包括SELinux,它禁止在没有安全层事先同意的情况下打开端口。要打开港口,请看这里。

#2


0  

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.

在这里,您只需从tomcat管理器中更改端口号,因为有些应用程序可能已经使用了您提供的端口8080。

Use the following method...

使用以下方法……

How to change the port of Tomcat from 8080 to 80?

如何将Tomcat的端口从8080更改为80?

#1


1  

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.

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

Edit: Ok, here comes the actionable part: open a terminal and run

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

netstat -t | grep 8080

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.

这将显示当前正在监听端口8080的任何内容。由于Ubuntu没有打开防火墙,这很可能是问题的根源。

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.

另一个编辑:最初的问题没有说明你在使用Android。这是一个重要的信息,因为Android包括SELinux,它禁止在没有安全层事先同意的情况下打开端口。要打开港口,请看这里。

#2


0  

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.

在这里,您只需从tomcat管理器中更改端口号,因为有些应用程序可能已经使用了您提供的端口8080。

Use the following method...

使用以下方法……

How to change the port of Tomcat from 8080 to 80?

如何将Tomcat的端口从8080更改为80?