2

I'm running a mvn clean tomcat7:run on my project and can't figure out the error. It starts, but I can never access the project on localhost:8080. I've tried looking this error up and testing my ports, but nothing has worked.

Here is what I'm getting:

[INFO] --- tomcat7-maven-plugin:2.2:run (default-cli) @ lcd ---
[INFO] Running war on http://localhost:80/
[INFO] Creating Tomcat server configuration at /Users/...
[INFO] create webapp with contextPath:
May 22, 2017 2:48:40 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-80"]
May 22, 2017 2:48:40 PM org.apache.coyote.AbstractProtocol init
SEVERE: Failed to initialize end point associated with ProtocolHandler ["http-bio-80"]
java.net.BindException: Permission denied (Bind failed) <null>:80
    at org.apache.tomcat.util.net.JIoEndpoint.bind(JIoEndpoint.java:407)
    at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:623)
    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:981)
    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:814)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
    at org.apache.catalina.startup.Tomcat.start(Tomcat.java:341)
    at org.apache.tomcat.maven.plugin.tomcat7.run.AbstractRunMojo.startContainer(AbstractRunMojo.java:1238)
    at org.apache.tomcat.maven.plugin.tomcat7.run.AbstractRunMojo.execute(AbstractRunMojo.java:592)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.net.BindException: Permission denied (Bind failed)
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
    at java.net.ServerSocket.bind(ServerSocket.java:375)
    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:394)
    ... 35 more
user6754289
  • 437
  • 1
  • 8
  • 26
  • Your server is trying to bind to port 80 (not 8080), so you need to check `http://localhost/` (without a port number). It seems some other program has still reserved that port. Could be that your app is running twice now. I never use Mac, but several programs try to bind to 80 to avoid firewall problems. A good candidate is Skype, f.e. – Stefan May 22 '17 at 19:08
  • Thanks, when I try to just go to localhost, it still does not connect. I tried to run some commands to see what is running on the ports 8080 or 80, but still no luck. – user6754289 May 22 '17 at 19:12
  • See this answer to check if that port is in use: https://stackoverflow.com/questions/3855127/find-and-kill-process-locking-port-3000-on-mac – Stefan May 22 '17 at 19:16

1 Answers1

2

I think this is just a matter of ports less than 1024 can only be opened by the root user. You can't open a port below 1024, if you don't have root privileges and from the code you posted in your comment, you seem to be trying to open port 80, not 8080.

Go to the tomcat configs and change the port to the 8080 or some port > 1024

<plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.3-SNAPSHOT</version>
        <configuration>
          <url>http://localhost:8080/manager/text</url>
        </configuration>
</plugin>

or other port you want, but obove 1024

developer_hatch
  • 15,898
  • 3
  • 42
  • 75
  • That is already in my pom... ` org.apache.tomcat.maven tomcat7-maven-plugin 2.2 ${CONTEXT_PATH} ` – user6754289 May 22 '17 at 19:00
  • Are you using a linux os or windows os? – developer_hatch May 22 '17 at 19:01
  • You have two options here, I'm sure, or you run your tomcat as root, or you change the port where tomcat is initialized (yours is 80, usually tomcat opens in port 8080), you can download a new tomcat to get the default configurations – developer_hatch May 22 '17 at 19:13
  • Ok, so change my tomcat config to run on 8080? or change the pom.xml? Sorry this is the first time I've done a maven build with tomcat. Or would you suggest uninstall tomcat and reinstall to get new defaults? – user6754289 May 22 '17 at 19:15
  • You can tell the port of your tomcat via .pom, like I updated in my answer – developer_hatch May 22 '17 at 19:15
  • Exactly, you can get the defaults by uninstalling it and installing again, or try that command – developer_hatch May 22 '17 at 19:16
  • Still no luck. Looks like it is starting now as I don't have the java.net.bind exception, but when I try to access localhost:8080, it doesn't connect – user6754289 May 22 '17 at 19:45
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/144867/discussion-between-damian-lattenero-and-karmesto). – developer_hatch May 22 '17 at 19:51
  • There's a good explanation with a nice solution for re-routing access to ports 80 and 443 to 8080 and 8081, respectively, at https://timothy-quinn.com/java-net-bindexception-permission-denied-null-80 – Gregor May 28 '18 at 16:08