launchdarkly / api-client-java

LaunchDarkly API Client for Java
Other
4 stars 8 forks source link

Exception when calling Configuration.getDefaultApiClient() #10

Closed ghost closed 3 years ago

ghost commented 3 years ago

I'm trying to instantiate the Java API client, as mentioned in the documentation:

ApiClient apiClient = Configuration.getDefaultApiClient();

When I call this, I get the following exception:

java.lang.NoClassDefFoundError: org/threeten/bp/temporal/TemporalAccessor
    at com.launchdarkly.api.JSON.<init>(JSON.java:49)
    at com.launchdarkly.api.ApiClient.init(ApiClient.java:125)
    at com.launchdarkly.api.ApiClient.<init>(ApiClient.java:85)
    at com.launchdarkly.api.Configuration.<clinit>(Configuration.java:18)

I'm referencing a local copy of the JAR file downloaded from Maven's repository ( https://search.maven.org/artifact/com.launchdarkly/api-client/6.0.0/jar ). Is it not possible to reference the Java API client in this fashion?

bwoskow-ld commented 3 years ago

Hi @jehrenzweig,

The api-client jar artifact is not an uber jar. The api-client jar only includes the bytecode for the LaunchDarkly API client and not for any dependency types including org.threeten.bp.temporal.TemporalAccessor.

If you are manually adding local jars to your classpath then you also need to manually add this artifact's dependencies (as well as potentially their dependencies too, and so forth).

Alternatively, we strongly recommend using a build tool like Maven or Gradle which would take care of dependency management in a more automated fashion.

Cheers, @bwoskow-ld

ghost commented 3 years ago

Great, thank you for the explanation.