3

I am deploying archetype tomee-cf using the command mvn tomee:run and I am getting address already in use issue. I checked whether something is running on ports 8005, 8009, 8080 and 8443 and found only a system IPv4 listening to 8005.

I expect the application to run on localhost.

EDIT (from comments): the command netstat -o -n -a | findstr 0.0:8005 gives the output TCP 0.0.0.0:8005 0.0.0.0:0 LISTENING 4.

Log:

> INFO: Deployment of web application archive C:\Users\e4560\Desktop\address-manager\application\target\apache-tomee\webapps\ROOT.war has finished in 12,030 ms
Jan 18, 2019 10:31:57 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jan 18, 2019 10:31:57 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jan 18, 2019 10:31:57 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 12240 ms
Jan 18, 2019 10:31:57 AM org.apache.catalina.core.StandardServer await
SEVERE: StandardServer.await: create[localhost:8005]:
java.net.BindException: Address already in use: JVM_Bind
        at java.net.DualStackPlainSocketImpl.bind0(Native Method)
        at java.net.DualStackPlainSocketImpl.socketBind(DualStackPlainSocketImpl.java:106)
        at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
        at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:190)
        at java.net.ServerSocket.bind(ServerSocket.java:375)
        at java.net.ServerSocket.<init>(ServerSocket.java:237)
        at org.apache.catalina.core.StandardServer.await(StandardServer.java:444)
        at org.apache.catalina.startup.Catalina.await(Catalina.java:782)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:728)
        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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:428)
Jan 18, 2019 10:31:57 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-8080"]
Jan 18, 2019 10:31:57 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
Jan 18, 2019 10:31:57 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Jan 18, 2019 10:31:57 AM org.apache.openejb.assembler.classic.Assembler destroyApplication
INFO: Undeploying app: C:\Users\e09340\Desktop\address-manager\application\target\apache-tomee\webapps\ROOT
Jan 18, 2019 10:31:57 AM org.apache.openejb.util.OptionsLog info
INFO: Using 'openjpa.Log=org.apache.openejb.openjpa.JULOpenJPALogFactory'
Jan 18, 2019 10:31:57 AM org.apache.openejb.assembler.classic.Assembler destroyApplication
INFO: Undeployed app: C:\Users\epom\Desktop\address-manager\application\target\apache-tomee\webapps\ROOT
Jan 18, 2019 10:31:57 AM org.apache.catalina.loader.WebappClassLoaderBase checkThreadLocalMapForLeaks
SEVERE: The web application [] created a ThreadLocal with key of type [com.netflix.hystrix.Hystrix$1] (value [com.netflix.hystrix.Hystrix$1@4eedec61]) and a value of type [com.netflix.hystrix.Hystrix.ConcurrentStack] (value [com.netflix.hystrix.Hystrix$ConcurrentStack@740a0cb2]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Jan 18, 2019 10:31:57 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-8080"]
Jan 18, 2019 10:31:57 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
Jan 18, 2019 10:31:57 AM org.apache.openejb.server.SimpleServiceManager stop
INFO: Stopping server services
Jan 18, 2019 10:31:57 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-8080"]
Jan 18, 2019 10:31:57 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-bio-8009"]
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
coolcoder
  • 27
  • 1
  • 9
  • Can you please post the output of the following command: ` lsof -itcp:8005`? In general: if there is already something running on one of the ports that Tomcat wants to bind on, then Tomcat will not start. So you have to make sure that all the ports required by Tomcat are free. Alternatively you can configure Tomcat to use different ports, though I would not recommend that. – Dennis H Jan 18 '19 at 11:17
  • I am using windows terminal.What is the command for windows? @DennisH> – coolcoder Jan 18 '19 at 11:21
  • 1
    Retrieve the process id: `netstat -o -n -a | findstr 0.0:8005` You can stop the process with: `taskkill /F /PID ` – Sander Wozniak Jan 18 '19 at 11:27
  • @DennisH output is TCP 0.0.0.0:8005 0.0.0.0:0 LISTENING 4 – coolcoder Jan 18 '19 at 11:47
  • @SanderWozniak TCP 0.0.0.0:8005 0.0.0.0:0 LISTENING 4 – coolcoder Jan 18 '19 at 11:48

1 Answers1

1

Run the maven command with -Dtomee-plugin.shutdown=8006, this should fix your problem.

Background

From your log, it appears that you are on a Windows machine. Windows 10 has an update demon which is always listening on the port 8005. More details are here .

You can also check which process is using the port with the help of the resource monitor.

enter image description here

Ram
  • 1,154
  • 6
  • 22
  • Which port to shut down?-Dtomee-plugin.shutdown=8006 or -Dtomee-plugin.shutdown=8005 .Do we need to run while generating archetype? – coolcoder Jan 18 '19 at 13:51
  • 2
    Execute command as `mvn tomee:run -Dtomee-plugin.shutdown=8006`. Which means you are telling maven to use port `8006` to shut down the application. By default, this port is `8005` – Ram Jan 18 '19 at 14:18
  • Thanks.We can also do so by adding following mvn conf in application pom.xml. 8006 < /tomeeShutdownPort > – coolcoder Jan 19 '19 at 11:39