共计 8818 个字符,预计需要花费 23 分钟才能阅读完成。
Tomcat 启动报错:Java.net.BindException: Permission denied:80
1,启动报错显示
[org.springframework.web.servlet.DispatcherServlet]FrameworkServlet 'springMvc': initialization completed in 382 ms | |
Jun 01, 2015 6:39:06 PM org.apache.coyote.http11.Http11Protocol start | |
SEVERE: Error starting endpoint | |
java.net.BindException: Permission denied <null>:80 | |
at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:549) | |
at org.apache.tomcat.util.net.JIoEndpoint.start(JIoEndpoint.java:565) | |
at org.apache.coyote.http11.Http11Protocol.start(Http11Protocol.java:207) | |
at org.apache.catalina.connector.Connector.start(Connector.java:1196) | |
at org.apache.catalina.core.StandardService.start(StandardService.java:540) | |
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) | |
at org.apache.catalina.startup.Catalina.start(Catalina.java:595) | |
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:601) | |
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) | |
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) | |
Caused by: java.net.BindException: Permission denied | |
at java.net.PlainSocketImpl.socketBind(Native Method) | |
at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376) | |
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:50) | |
at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:538) | |
... 12 more | |
Jun 01, 2015 6:39:06 PM org.apache.catalina.core.StandardService start | |
SEVERE: Failed to start connector [Connector[HTTP/1.1-80]] | |
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: java.net.BindException: Permission denied <null>:80 | |
at org.apache.catalina.connector.Connector.start(Connector.java:1203) | |
at org.apache.catalina.core.StandardService.start(StandardService.java:540) | |
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) | |
at org.apache.catalina.startup.Catalina.start(Catalina.java:595) | |
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:601) | |
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) | |
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) | |
Jun 01, 2015 6:39:06 PM org.apache.jk.common.ChannelSocket init | |
INFO: JK: ajp13 listening on /0.0.0.0:9109 | |
Jun 01, 2015 6:39:06 PM org.apache.jk.server.JkMain start | |
INFO: Jk running ID=0 time=0/17 config=null | |
Jun 01, 2015 6:39:06 PM org.apache.catalina.startup.Catalina start | |
INFO: Server startup in 6868 ms |
问题分析:在 SUSE 上只有 root 用户才可以访问 1024 以下的端口号,其余用户不能访问。
2,解决方案
2.1,修改 Tomcat 的 server.xml 配置文件,将端口修改为 8081(或者其他 1024 以上的端口号,不能与本机上的其它 Tomcat 端口冲突)
[root@tomcat57conf]# vim /usr/local/app/apache-tomcat-6.0.37_hechuang_lib/conf/server.xml | |
<Connector port="8081" protocol="HTTP/1.1" | |
connectionTimeout="30000" | |
maxThreads="2000" | |
acceptCount="2000" | |
URIEncoding="UTF-8" | |
redirectPort="9143" /> | |
<!-- A "Connector" using the shared thread pool--> |
2.2,然后使用 root 用户登录服务器,执行端口重定向命令:iptables -t nat -A PREROUTING -p tcp –dport 80 -j REDIRECT –to-port 8081。
意思就是当访问 80 端口时重定向到 8081 端口,这样,我们可以改成任何我们需要的端口啦。
[root@tomcat57conf]# iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8081 | |
[root@tomcat57conf]# |
2.3,切换到 tomcat 账号,启动 tomcat 服务
就可以正常访问了:
INFO: Deploying web application directory databox | |
[org.springframework.web.context.ContextLoader]Root WebApplicationContext: initialization started | |
[org.springframework.web.context.support.XmlWebApplicationContext]Refreshing Root WebApplicationContext: startup date [Mon Jun 01 18:42:44 CST 2015]; root of context hierarchy | |
[org.springframework.beans.factory.xml.XmlBeanDefinitionReader]Loading XML bean definitions from class path resource [spring.xml] | |
[org.springframework.beans.factory.xml.XmlBeanDefinitionReader]Loading XML bean definitions from class path resource [spring-mybatis.xml] | |
[org.springframework.beans.factory.config.PropertyPlaceholderConfigurer]Loading properties file from class path resource [config.properties] | |
[org.springframework.beans.factory.support.DefaultListableBeanFactory]Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@71d7c3ff: defining beans [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,receiptService,posmonitorService,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,dataSource,sqlSessionFactory,org.mybatis.spring.mapper.MapperScannerConfigurer#0,transactionManager,transactionAdvice,org.springframework.aop.config.internalAutoProxyCreator,transactionPointcut,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,receiptMapper,posMonitorLogsMapper]; root of factory hierarchy | |
[com.alibaba.druid.pool.DruidAbstractDataSource]maxIdle is deprecated | |
[com.alibaba.druid.pool.DruidDataSource]{dataSource-1} inited | |
[org.springframework.web.context.ContextLoader]Root WebApplicationContext: initialization completed in 1433 ms | |
[org.springframework.web.servlet.DispatcherServlet]FrameworkServlet 'springMvc': initialization started | |
[org.springframework.web.context.support.XmlWebApplicationContext]Refreshing WebApplicationContext for namespace 'springMvc-servlet': startup date [Mon Jun 01 18:42:45 CST 2015]; parent: Root WebApplicationContext | |
[org.springframework.beans.factory.xml.XmlBeanDefinitionReader]Loading XML bean definitions from class path resource [spring-mvc.xml] | |
[org.springframework.beans.factory.support.DefaultListableBeanFactory]Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@5d4ee178: defining beans [receiptController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,mappingJacksonHttpMessageConverter,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0,org.springframework.web.servlet.view.InternalResourceViewResolver#0,multipartResolver,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@71d7c3ff | |
[org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping]Mapped URL path [/receiptController/receiveReceiptData] onto handler 'receiptController' | |
[org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping]Mapped URL path [/receiptController/receiveReceiptData.*] onto handler 'receiptController' | |
[org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping]Mapped URL path [/receiptController/receiveReceiptData/] onto handler 'receiptController' | |
[org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping]Mapped URL path [/receiptController/receivePosInfoData] onto handler 'receiptController' | |
[org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping]Mapped URL path [/receiptController/receivePosInfoData.*] onto handler 'receiptController' | |
[org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping]Mapped URL path [/receiptController/receivePosInfoData/] onto handler 'receiptController' | |
[org.springframework.web.servlet.DispatcherServlet]FrameworkServlet 'springMvc': initialization completed in 377 ms | |
Jun 01, 2015 6:42:45 PM org.apache.coyote.http11.Http11Protocol start | |
INFO: Starting Coyote HTTP/1.1 on http-8081 | |
Jun 01, 2015 6:42:45 PM org.apache.jk.common.ChannelSocket init | |
INFO: JK: ajp13 listening on /0.0.0.0:9109 | |
Jun 01, 2015 6:42:45 PM org.apache.jk.server.JkMain start | |
INFO: Jk running ID=0 time=0/16 config=null | |
Jun 01, 2015 6:42:45 PM org.apache.catalina.startup.Catalina start | |
INFO: Server startup in 6827 ms | |
^C |
RedHat Linux 5.5 安装 JDK+Tomcat 并部署 Java 项目 http://www.linuxidc.com/Linux/2015-02/113528.htm
Tomcat 权威指南 (第二版)(中英高清 PDF 版 + 带书签) http://www.linuxidc.com/Linux/2015-02/113062.htm
Tomcat 安全配置与性能优化 http://www.linuxidc.com/Linux/2015-02/113060.htm
Linux 下使用 Xshell 查看 Tomcat 实时日志中文乱码解决方案 http://www.linuxidc.com/Linux/2015-01/112395.htm
CentOS 64-bit 下安装 JDK 和 Tomcat 并设置 Tomcat 开机启动操作步骤 http://www.linuxidc.com/Linux/2015-01/111485.htm
CentOS 6.5 下安装 Tomcat http://www.linuxidc.com/Linux/2015-01/111415.htm
Tomcat 的详细介绍 :请点这里
Tomcat 的下载地址 :请点这里
本文永久更新链接地址 :http://www.linuxidc.com/Linux/2015-06/118382.htm
