Skip to content

okhttp3 runtime error #448

@scroogemcfawk

Description

@scroogemcfawk

I'm currently developing a client for one opensource project (LUWRAIN, a platform for blind and partly-sighted people) and encountered a problem I can not solve. I'm not really sure if this issue relates to bigbone, but I don't know where to ask for help ether.

So, when I run my program from IDE everything works, but when LUWRAIN starts it, I get this:

java.lang.NoSuchFieldError: Companion
        at okhttp3.internal.Util.<clinit>(Util.kt:70)
        at okhttp3.internal.concurrent.TaskRunner.<clinit>(TaskRunner.kt:309)
        at okhttp3.ConnectionPool.<init>(ConnectionPool.kt:41)
        at okhttp3.ConnectionPool.<init>(ConnectionPool.kt:47)
        at okhttp3.OkHttpClient$Builder.<init>(OkHttpClient.kt:471)
        at social.bigbone.MastodonClient$Builder.<init>(MastodonClient.kt:804)
        at com.github.scroogemcfawk.mastodon.api.Mastodon.initClient(Mastodon.kt:55)
        at com.github.scroogemcfawk.mastodon.api.Mastodon.<init>(Mastodon.kt:49)
        at org.luwrain.app.mastodon.StartingLayout.onMailAddress(StartingLayout.java:47)
        at org.luwrain.controls.WizardArea$WizardClickable.click(WizardArea.java:75)
        at org.luwrain.controls.WizardArea.onClick(WizardArea.java:260)
        at org.luwrain.controls.WizardArea.onInputEvent(WizardArea.java:272)
        at org.luwrain.app.base.LayoutBase$1.onInputEvent(LayoutBase.java:276)
        at org.luwrain.core.EventDispatching.lambda$onInputEvent$2(EventDispatching.java:150)
        at org.luwrain.core.Base.unsafeAreaOperation(Base.java:288)
        at org.luwrain.core.EventDispatching.onInputEvent(EventDispatching.java:138)
        at org.luwrain.core.EventDispatching.onEvent(EventDispatching.java:80)
        at org.luwrain.core.Base.eventLoop(Base.java:111)
        at org.luwrain.core.Core.run(Core.java:70)
        at org.luwrain.core.Launch.run(Launch.java:108)
        at org.luwrain.core.Init.main(Init.java:75)

I assume there is a problem with okhttp3 library version.

I checked the sources of your library, there is okhttp3 version 4.12.0 specified.
I checked what classes are loaded in LUWRAIN process (with -Xlog:class+load) when it starts my application, it says that only okhttp3 version 4.12.0 jar is loaded.

The whole project is built with maven + ant, so there is a lot of places that can may cause problems, but I excluded other versions in ant build file (because okhttp version 2* appears in the libraries of LUWRAIN sometimes), still didn't help.

The build file looks like this:

<project name="luwrain-app-mastodon" default="jar" basedir=".">
    <!-- todo#smf add property -->
    <typedef resource="org/jetbrains/kotlin/ant/antlib.xml" classpath="/home/smf/opt/kotlinc/lib/kotlin-ant.jar"/>
    <path id="classpath">
        <pathelement location="."/>
        <fileset dir="../release/lib">
            <include name="**/*.jar"/>
            <exclude name="**/*okhttp-2*.jar"/>
            <exclude name="**/*okhttp-3*.jar"/>
            <exclude name="**/*okhttp-4.3*.jar"/>
        </fileset>
        <fileset dir="../release/jar">
            <include name="**/*.jar"/>
            <exclude name="**/*okhttp-2*.jar"/>
            <exclude name="**/*okhttp-3*.jar"/>
            <exclude name="**/*okhttp-4.3*.jar"/>
        </fileset>
    </path>
    <path id="mainjar">
        <pathelement location="."/>
        <fileset dir="jar">
            <include name="**/*.jar"/>
        </fileset>
    </path>
    <target name="clean">
        <delete dir="build"/>
        <delete dir="jar"/>
        <delete dir="target"/>
    </target>
    <target name="compile" depends="clean">
        <mkdir dir="build"/>
        <mkdir dir="build/main"/>
        <javac includeantruntime="false" encoding="UTF-8" srcdir="src/main/" destdir="build/main" source="17"
               target="17" debug="true" debuglevel="lines,vars,source">
            <classpath refid="classpath"/>
            <compilerarg value="-verbose"/>
            <compilerarg value="-Xlint:unchecked"/>
            <compilerarg value="-Xlint:deprecation"/>
            <compilerarg value="-Xlint:-options"/>
            <withKotlin/>
        </javac>
    </target>
    <target name="jar" depends="compile">
        <mkdir dir="jar"/>
        <jar jarfile="jar/luwrain-app-mastodon.jar">
            <manifest>
                <section name="org/luwrain">
                    <attribute name="Extensions" value="org.luwrain.app.mastodon.Extension"/>
                </section>
            </manifest>
            <fileset dir="./build/main">
                <include name="**/*.class"/>
            </fileset>
            <fileset dir="./src/main/resources">
                <include name="**/*"/>
            </fileset>
        </jar>
    </target>
    <target name="compile-test" depends="jar">
        <mkdir dir="build"/>
        <mkdir dir="build/test"/>
        <javac srcdir="src/test/java" destdir="build/test" source="1.8" target="1.8">
            <classpath>
                <path refid="classpath"/>
                <path refid="mainjar"/>
            </classpath>
        </javac>
    </target>
    <target name="jar-test" depends="compile-test">
        <jar jarfile="jar/luwrain-app-mastodon-test.jar">
            <fileset dir="./build/test">
                <include name="**/*.class"/>
            </fileset>
        </jar>
    </target>
    <target name="junit" depends="jar-test">
        <junit printsummary="withOutAndErr">
            <classpath>
                <path refid="classpath"/>
                <path refid="mainjar"/>
            </classpath>
            <formatter type="xml" usefile="true"/>
            <batchtest fork="yes">
                <fileset dir="build/test">
                    <include name="**/*Test.class"/>
                </fileset>
            </batchtest>
        </junit>
    </target>
</project>

The stack trace changes, if I use okhttp3 libraries of different versions (3.14.9, 4.3.1).

I tried everything I could try and at this point I don't have any ideas how to solve this problem.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions