Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cant start tomcat with spring boot on linux

Suddenly I cant start my embedded tomcat.

I get:

[main] ERROR o.a.coyote.http11.Http11NioProtocol - Failed to start end point associated with ProtocolHandler ["http-nio-86"]
java.net.SocketException: Permission denied

I tried changing tomcat port, I tried setting permissions: chmod 777 src/ -R

I use linux Mint 17

I have no idea what to do...

This is the stacktrace:

    [main] ERROR o.a.coyote.http11.Http11NioProtocol - Failed to start end point associated with ProtocolHandler ["http-nio-86"]
java.net.SocketException: Permission denied
    at sun.nio.ch.Net.bind0(Native Method) ~[na:1.7.0_67]
    at sun.nio.ch.Net.bind(Net.java:444) ~[na:1.7.0_67]
    at sun.nio.ch.Net.bind(Net.java:436) ~[na:1.7.0_67]
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214) ~[na:1.7.0_67]
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) ~[na:1.7.0_67]
    at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:473) ~[tomcat-embed-core-7.0.52.jar:7.0.52]
    at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:647) ~[tomcat-embed-core-7.0.52.jar:7.0.52]
    at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:449) ~[tomcat-embed-core-7.0.52.jar:7.0.52]
    at org.apache.catalina.connector.Connector.startInternal(Connector.java:1007) [tomcat-embed-core-7.0.52.jar:7.0.52]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-7.0.52.jar:7.0.52]
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:459) [tomcat-embed-core-7.0.52.jar:7.0.52]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-7.0.52.jar:7.0.52]
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:731) [tomcat-embed-core-7.0.52.jar:7.0.52]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-7.0.52.jar:7.0.52]
    at org.apache.catalina.startup.Tomcat.start(Tomcat.java:341) [tomcat-embed-core-7.0.52.jar:7.0.52]
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:79) [spring-boot-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:69) [spring-boot-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:270) [spring-boot-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:145) [spring-boot-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:159) [spring-boot-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:132) [spring-boot-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476) [spring-context-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120) [spring-boot-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:648) [spring-boot-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) [spring-boot-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:909) [spring-boot-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:898) [spring-boot-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at com.company.WebApplication.main(WebApplication.java:23) [classes/:na]
- 2014-10-30 10:30:51,609 [main] ERROR o.a.catalina.core.StandardService - Failed to start connector [Connector[org.apache.coyote.http11.Http11NioProtocol-86]]
org.apache.catalina.LifecycleException: Failed to start component [Connector[org.apache.coyote.http11.Http11NioProtocol-86]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) [tomcat-embed-core-7.0.52.jar:7.0.52]
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:459) ~[tomcat-embed-core-7.0.52.jar:7.0.52]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-7.0.52.jar:7.0.52]
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:731) [tomcat-embed-core-7.0.52.jar:7.0.52]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-7.0.52.jar:7.0.52]
    at org.apache.catalina.startup.Tomcat.start(Tomcat.java:341) [tomcat-embed-core-7.0.52.jar:7.0.52]
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:79) [spring-boot-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:69) [spring-boot-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:270) [spring-boot-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:145) [spring-boot-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:159) [spring-boot-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:132) [spring-boot-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476) [spring-context-4.0.3.RELEASE.jar:4.0.3.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120) [spring-boot-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:648) [spring-boot-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) [spring-boot-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:909) [spring-boot-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:898) [spring-boot-1.0.2.RELEASE.jar:1.0.2.RELEASE]
    at com.company.WebApplication.main(WebApplication.java:23) [classes/:na]
Caused by: org.apache.catalina.LifecycleException: service.getName(): "Tomcat";  Protocol handler start failed
    at org.apache.catalina.connector.Connector.startInternal(Connector.java:1014) ~[tomcat-embed-core-7.0.52.jar:7.0.52]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-7.0.52.jar:7.0.52]
    ... 18 common frames omitted
Caused by: java.net.SocketException: Permission denied
    at sun.nio.ch.Net.bind0(Native Method) ~[na:1.7.0_67]
    at sun.nio.ch.Net.bind(Net.java:444) ~[na:1.7.0_67]
    at sun.nio.ch.Net.bind(Net.java:436) ~[na:1.7.0_67]
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214) ~[na:1.7.0_67]
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) ~[na:1.7.0_67]
    at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:473) ~[tomcat-embed-core-7.0.52.jar:7.0.52]
    at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:647) ~[tomcat-embed-core-7.0.52.jar:7.0.52]
    at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:449) ~[tomcat-embed-core-7.0.52.jar:7.0.52]
    at org.apache.catalina.connector.Connector.startInternal(Connector.java:1007) ~[tomcat-embed-core-7.0.52.jar:7.0.52]
    ... 19 common frames omitted
- 2014-10-30 10:30:51,609 [main] INFO  o.a.coyote.http11.Http11NioProtocol - Stopping ProtocolHandler ["http-nio-86"]
- 2014-10-30 10:30:51,609 [main] INFO  o.a.coyote.http11.Http11NioProtocol - Pausing ProtocolHandler ["http-nio-86"]
- 2014-10-30 10:30:51,609 [main] INFO  o.a.catalina.core.StandardService - Stopping service Tomcat
- 2014-10-30 10:30:51,612 [localhost-startStop-1] ERROR o.a.c.loader.WebappClassLoader - The web application [] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.
- 2014-10-30 10:30:51,612 [localhost-startStop-1] ERROR o.a.c.loader.WebappClassLoader - The web application [] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] but has failed to stop it. This is very likely to create a memory leak.
- 2014-10-30 10:30:51,612 [localhost-startStop-1] ERROR o.a.c.loader.WebappClassLoader - The web application [] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] but has failed to stop it. This is very likely to create a memory leak.
- 2014-10-30 10:30:51,613 [localhost-startStop-1] ERROR o.a.c.loader.WebappClassLoader - The web application [] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] but has failed to stop it. This is very likely to create a memory leak.
- 2014-10-30 10:30:51,613 [localhost-startStop-1] ERROR o.a.c.loader.WebappClassLoader - The web application [] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak.
Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:135)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:648)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:311)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:909)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:898)
    at com.company.WebApplication.main(WebApplication.java:23)
Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:106)
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:69)
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:270)
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:145)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:159)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:132)
    ... 7 more
Caused by: java.lang.IllegalStateException: Tomcat connector in failed state
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:102)
    ... 12 more

Please help me.

like image 476
Ido Barash Avatar asked Oct 30 '14 08:10

Ido Barash


People also ask

Is spring boot compatible with Tomcat 10?

Spring boot does not work with Tomcat 10 · Issue #22414 · spring-projects/spring-boot · GitHub.

Do I need to install Tomcat to run spring boot?

No, it won't. It starts an embedded container. Don't try random things to fix an issue.

Does spring boot use Tomcat by default?

By default, Spring Boot provides an embedded Apache Tomcat build. By default, Spring Boot configures everything for you in a way that's most natural from development to production in today's platforms, as well as in the leading platforms-as-a-service.


1 Answers

Linux doesn't allow a normal user to bind to a TCP port that's <= 1024. There's a discussion of the reasons for that here. You're attempting to bind to 86 and, therefore, it's failing with "Permission denied". The quickest and safest solution is to configure the port with a value that's > 1024.

As you're using Boot's embedded Tomcat instance, the port's configured in application.properties using the server.port property.

like image 76
Andy Wilkinson Avatar answered Sep 27 '22 18:09

Andy Wilkinson