DiUS / pact-workshop-jvm

Example JVM project for the Pact workshop
Apache License 2.0
110 stars 64 forks source link

Error in Step 1 #4

Closed andysummylife closed 4 years ago

andysummylife commented 6 years ago

Hi, I've tried to clone and run the example but upon running the client in Step 1 with

$ ./gradlew :consumer:run

I can encounter an error, has anyone else seen the following?

Exception in thread "main" org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:8080 refused
        at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:190)
        at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
        at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:640)
        at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)
        at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
        at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1066)
        at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1044)
        at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:515)
        at groovyx.net.http.RESTClient.get(RESTClient.java:119)

I've run the :consumer:run task in an IDE with a breakpoint on Client.groovy line 27 and checked port 8080 and found nothing running. Both dropwizard and springboot run fine independently from the run and bootRun tasks respectively, so suspect an orchestration problem when bringing the server up.

Versions:

Also tried on a colleagues machine of similar spec.

Thanks in advance

danielbryantuk commented 6 years ago

This one initially stumped me too @andysummylife -- I believe the README documentation is at fault, because running the consumer correctly (as in Step 1 of the README) assumes that you already have a provider running.

The error you're seeing makes sense, as it is effectively saying "the consumer (client) can't connect to the non-existent provider (server) that should be running on localhost:8080" :-)

The fix is to execute the following (blocking) command to run a provider before trying to run the consumer:

./gradlew :providers:dropwizard-provider:run