1

I try connect to influxDb in my Java code:
InfluxDB influxDB = InfluxDBFactory.connect("http://serverIp:8086", "admin", "admin"); I get error:

Exception in thread "main" java.lang.NoClassDefFoundError: okhttp3/Interceptor
    at org.influxdb.InfluxDBFactory.connect(InfluxDBFactory.java:47)
    at InfluxDbConnector.main(InfluxDbConnector.java:15)
Caused by: java.lang.ClassNotFoundException: okhttp3.Interceptor
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 2 more

I use Maven and dependency in pom:

   <dependency>
        <groupId>org.influxdb</groupId>
        <artifactId>influxdb-java</artifactId>
        <version>2.7</version>
        <scope>system</scope>
        <systemPath>${project.basedir}/src/main/resources/lib/influxdb-java-2.7.jar</systemPath>
    </dependency>

What okhttp3 dependency need add? Or how resolve this problem?

1 Answer 1

1

You are missing the com.squareup.okhttp3 dependency. Indeed, according to Maven Repository your InfluxDB dependency itself has a set of Compile dependencies.

Please see here for the complete list of those.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.