javaportdropwizardjetty-8

SocketConnector 8081 - Address Already in use


I am trying to run 2 Dropwizard Server applications on 2 different ports 8080 and 9000.The first application starts successfully but I keep getting the below exception when I try to run on port 9000. What I am not understanding is that why are 2 ports being used by the application and how do I enforce my application to use a different port number for the second port

INFO  [2014-03-22 17:17:28,031] org.eclipse.jetty.server.AbstractConnector: Started    
InstrumentedBlockingChannelConnector@0.0.0.0:9000 
WARN  [2014-03-22 17:17:28,033] org.eclipse.jetty.util.component.AbstractLifeCycle: FAILED   
SocketConnector@0.0.0.0:8081: java.net.BindException: Address already in use
! java.net.BindException: Address already in use
! at org.eclipse.jetty.server.bio.SocketConnector.newServerSocket(SocketConnector.java:96)    
~[jetty-server-8.1.10.v20130312.jar:8.1.10.v20130312]
! at org.eclipse.jetty.server.bio.SocketConnector.open(SocketConnector.java:85) ~[jetty-
server-8.1.10.v20130312.jar:8.1.10.v20130312]
! at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:316) ~
[jetty-server-8.1.10.v20130312.jar:8.1.10.v20130312]
! at org.eclipse.jetty.server.bio.SocketConnector.doStart(SocketConnector.java:156) ~
[jetty-server-8.1.10.v20130312.jar:8.1.10.v20130312]
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) 
[jetty-util-8.1.10.v20130312.jar:8.1.10.v20130312]
! at org.eclipse.jetty.server.Server.doStart(Server.java:291) [jetty-server-
8.1.10.v20130312.jar:8.1.10.v20130312]
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) 
[jetty-util-8.1.10.v20130312.jar:8.1.10.v20130312]
! at com.yammer.dropwizard.cli.ServerCommand.run(ServerCommand.java:48) [dropwizard-core-
0.6.2.jar:na]
! at com.yammer.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:39) 
[dropwizard-core-0.6.2.jar:na]
! at com.yammer.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:58) 
[dropwizard-core-0.6.2.jar:na]
! at com.yammer.dropwizard.cli.Cli.run(Cli.java:53) [dropwizard-core-0.6.2.jar:na]
! at com.yammer.dropwizard.Service.run(Service.java:61) [dropwizard-core-0.6.2.jar:na]
! at com.paypal.demandgen.places.indexing.IndexingServer.main(IndexingServer.java:96)    
[classes/:na]
WARN  [2014-03-22 17:17:28,034] org.eclipse.jetty.util.component.AbstractLifeCycle: FAILED or

Solution

  • Dropwizard actually serves up two sites: the main site, and an admin site on a different port. The admin section allows you to view metrics and healthchecks on your site.

    In this instance, the problem is due to the Admin client, which by default runs on port 8081. So you need to also set -Ddw.http.adminPort=9001 (for instance)