Search code examples
javamavenneo4jjersey

neo4j server-extension example -- java.net.BindException: Address already in use


I'm going through the neo4j server-extension example that is posted in github---and when running mvn package I get the "java.net.BindException:Address already in use" for port 7474 on the MovieServiceIntegrationTest.

I've looked at the port through the commands 'lsof -i:7474' and 'netstat -n' and I do not see anything interfering.

I've also tried on linux (initially on os X) and I get the same problem.

What is the best next step to investigate the error?

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running example.extension.movies.MovieServiceIntegrationTest
server.baseUri() = http://localhost:7474/
05:46:21.067 [main] WARN  o.e.j.server.handler.ContextHandler - o.e.j.s.ServletContextHandler@29314cc9{/,null,null} contextPath ends with /
05:46:21.070 [main] WARN  o.e.j.server.handler.ContextHandler - Empty contextPath
05:46:21.078 [main] INFO  org.eclipse.jetty.server.Server - jetty-9.0.5.v20130815
05:46:21.133 [main] INFO  o.e.j.server.handler.ContextHandler - Started o.e.j.s.h.MovedContextHandler@7b208b45{/,null,AVAILABLE}
Mar 23, 2015 5:46:21 AM com.sun.jersey.api.core.PackagesResourceConfig init
INFO: Scanning for root resource and provider classes in the packages:
  example.extension.movies
Mar 23, 2015 5:46:21 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses
INFO: Root resource classes found:
  class example.extension.movies.MovieResource
Mar 23, 2015 5:46:21 AM com.sun.jersey.api.core.ScanningResourceConfig init
INFO: No provider classes found.
Mar 23, 2015 5:46:21 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.9 09/02/2011 11:17 AM'
05:46:21.588 [main] INFO  o.e.j.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@ba354ca{/movie,null,AVAILABLE}
Mar 23, 2015 5:46:21 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.9 09/02/2011 11:17 AM'
05:46:21.757 [main] INFO  o.e.j.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@7b4acdc2{/db/manage,null,AVAILABLE}
Mar 23, 2015 5:46:21 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.9 09/02/2011 11:17 AM'
05:46:21.957 [main] INFO  o.e.j.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@736048ed{/db/data,null,AVAILABLE}
05:46:22.061 [main] INFO  o.e.j.w.StandardDescriptorProcessor - NO JSP Support for /browser, did not find org.apache.jasper.servlet.JspServlet
05:46:22.078 [main] INFO  o.e.j.server.handler.ContextHandler - Started o.e.j.w.WebAppContext@64693226{/browser,jar:file:/Users/brianchase/.m2/repository/org/neo4j/app/neo4j-browser/2.1.4/neo4j-browser-2.1.4.jar!/browser,AVAILABLE}
Mar 23, 2015 5:46:22 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.9 09/02/2011 11:17 AM'
05:46:22.191 [main] INFO  o.e.j.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@29314cc9{/,null,AVAILABLE}
05:46:22.251 [main] WARN  o.e.j.u.component.AbstractLifeCycle - FAILED ServerConnector@3f985a86{HTTP/1.1}{localhost:7474}: java.net.BindException: Address already in use
java.net.BindException: Address already in use

Port investigation (7474 neo4j server in listen):

Computer:~ user$ lsof -i:7474
COMMAND PID       USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
java    421 user  137u  IPv6 0x4c075845f5b86ccd      0t0  TCP localhost:7474 (LISTEN)

Netstat:

Active Internet connections
Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)    
tcp4       0      0  192.168.44.208.49303   65.115.96.238.80       SYN_SENT   
tcp4       0      0  192.168.44.208.49301   209.197.20.103.80      ESTABLISHED
tcp4       0      0  192.168.44.208.49300   4.31.28.74.80          ESTABLISHED
tcp4     164      0  192.168.44.208.49276   52.0.233.188.80        CLOSE_WAIT 
tcp4       0      0  192.168.44.208.49208   108.160.170.34.80      ESTABLISHED
tcp4      37      0  192.168.44.208.49186   108.160.165.211.443    CLOSE_WAIT 
tcp4      37      0  192.168.44.208.49185   108.160.165.211.443    CLOSE_WAIT 
tcp4      37      0  192.168.44.208.49184   108.160.165.211.443    CLOSE_WAIT 
tcp4      37      0  192.168.44.208.49183   108.160.165.211.443    CLOSE_WAIT 
tcp4       0      0  192.168.44.208.49178   17.172.233.120.5223    ESTABLISHED
tcp4       0      0  192.168.44.208.49177   17.110.227.101.5223    ESTABLISHED
tcp4      37      0  192.168.44.208.49170   108.160.166.141.443    CLOSE_WAIT 
udp4       0      0  *.58920                *.*                               
udp4       0      0  *.17500                *.*                               
udp4       0      0  *.53249                *.*                               
udp4       0      0  192.168.44.208.123     *.*                               
udp6       0      0  fe80::2ef0:eeff:.123   *.*                               
udp6       0      0  fe80::8402:97ff:.123   *.*                               
udp6       0      0  fe80::1%lo0.123        *.*                               
udp4       0      0  127.0.0.1.123          *.*                               
udp6       0      0  ::1.123                *.*                               
udp6       0      0  *.123                  *.*                               
udp4       0      0  *.123                  *.*                               
udp6       0      0  *.5353                 *.*                               
udp4       0      0  *.5353                 *.*                               
udp4       0      0  *.*                    *.*                               
udp4       0      0  *.58003                *.*                               
udp4       0      0  *.*                    *.*                               
udp4       0      0  *.*                    *.*                               
udp4       0      0  *.*                    *.*                               
udp4       0      0  *.*                    *.*                               
udp6       0      0  *.5353                 *.*                               
udp4       0      0  *.*                    *.*                               
udp4       0      0  *.*                    *.*                               
udp4       0      0  *.*                    *.*                               
udp4       0      0  *.*                    *.*                               
udp4       0      0  *.*                    *.*                               
udp4       0      0  *.*                    *.*                               
udp6       0      0  *.5353                 *.*                               
udp4       0      0  *.5353                 *.*                               
udp46      0      0  *.*                    *.*                               
udp4       0      0  *.*                    *.*                               
udp4       0      0  *.*                    *.*                               
udp4       0      0  *.*                    *.*                               
udp4       0      0  *.*                    *.*                               
udp4       0      0  *.*                    *.*                               
udp4       0      0  *.*                    *.*                               
udp4       0      0  *.*                    *.*                               
udp4       0      0  *.*                    *.*                               
udp4       0      0  *.*                    *.*                               
udp46      0      0  *.*                    *.*                               
udp4       0      0  *.*                    *.*                               
udp4       0      0  *.*                    *.*                               
udp4       0      0  *.137                  *.*                               
udp4       0      0  *.138                  *.* 

Solution

  • It looks like you have a neo4j instance running when running the maven tests. Make sure you shut this down before running maven.

    Before running mvn, use jps to list all running java processes. The neo4j process is mentioned as Bootstrapper in jps' listing. Make sure that there is no such process.