influxdata / influxdb-java

Java client for InfluxDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

java.lang.NoSuchFieldError: Companion at com.squareup.okhttp3.internal.Util

LiMengyang990726 opened this issue · comments

The pom.xml that my project used is shown below

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>xx</groupId>
        <artifactId>xxx</artifactId>
        <version>xxxx</version>
    </parent>
    <artifactId>xxx</artifactId>

    <dependencies>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.15</version>
        </dependency>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2.1</version>
        </dependency>
        <dependency>
            <groupId>org.influxdb</groupId>
            <artifactId>influxdb-java</artifactId>
            <version>2.21</version>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>8</source>
                    <target>8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <relocations>
                                <relocation>
                                    <pattern>okhttp3</pattern>
                                    <shadedPattern>flink.influxdb.shaded.okhttp3</shadedPattern>
                                </relocation>
                            </relocations>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

I have make sure that no other okhttp3 version exists in the repo, and the only okhttp3 version I am using is 4.9.0 (which is introduced by influxdb-java). To avoid any possible conflict, I have shaded the okhttp3 path.

I am running the job in a spark environment, and I encountered the error shown below,

23/05/16 11:58:10 ERROR ApplicationMaster: User class threw exception: java.lang.NoSuchFieldError: Companion
java.lang.NoSuchFieldError: Companion
	at flink.influxdb.shaded.okhttp3.internal.Util.<clinit>(Util.kt:71)
	at flink.influxdb.shaded.okhttp3.internal.concurrent.TaskRunner.<clinit>(TaskRunner.kt:309)
	at flink.influxdb.shaded.okhttp3.ConnectionPool.<init>(ConnectionPool.kt:41)
	at flink.influxdb.shaded.okhttp3.ConnectionPool.<init>(ConnectionPool.kt:47)
	at flink.influxdb.shaded.okhttp3.OkHttpClient$Builder.<init>(OkHttpClient.kt:471)
	at org.influxdb.InfluxDBFactory.connect(InfluxDBFactory.java:30)