cloudant / java-cloudant

A Java client for Cloudant
Apache License 2.0
79 stars 68 forks source link

Readme.md does not list all maven dependencies that are needed. #393

Closed MaheshIBM closed 7 years ago

MaheshIBM commented 7 years ago

import java.util.List; import java.net.MalformedURLException; import java.net.URL;

import com.cloudant.client.api.ClientBuilder; import com.cloudant.client.api.CloudantClient; public class Program {

public static void main(String[] args) {
    try {
        CloudantClient client = ClientBuilder.url(new URL("http://127.0.0.1:5984")).build();
        System.out.println("Server Version: " + client.serverVersion());

        // Get a List of all the databases this Cloudant account
        List<String> databases = client.getAllDbs();
        System.out.println("All my databases : ");
        for ( String db : databases ) {
            System.out.println(db);
        }

    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

}


This gave a cnf for com.cloudant.http.HTTPConnectionRequestInterceptor. It started working after i added the following dependency.

``` xml
        <dependency>
            <groupId>com.cloudant</groupId>
            <artifactId>cloudant-http</artifactId>
            <version>2.10.0</version>
        </dependency>

But I cannot reproduce the issue even after I now delete the dependency from pom.xml. It may help to include this dependency in the list of dependencies to use cloudant-client.

ricellis commented 7 years ago

The cloudant-http dependency is a required dependency of the cloudant-client artifact and is declared as such in the cloudant-client pom.xml as you can see here: https://repo1.maven.org/maven2/com/cloudant/cloudant-client/2.10.0/cloudant-client-2.10.0.pom

<dependency>
  <groupId>com.cloudant</groupId>
  <artifactId>cloudant-http</artifactId>
  <version>2.10.0</version>
  <scope>compile</scope>
</dependency>

It shouldn't be added to the list of dependencies in the README.md because a consuming project should only have a dependency on cloudant-client, correct parsing of the pom will bring in any transitive dependencies required.

Adding cloudant-http directly to the consuming project's pom.xml could lead to problems in future, for example if we changed cloudant-client dependencies, because the consuming project might inadvertently pull an un-needed dependency.

As you've said the problem is not reproducible, so it sounds like you had some Maven blip or something.

MaheshIBM commented 7 years ago

Thanks and sorry for the trouble, Clearly seems like a problem with the first time maven tried to download the dependencies.