Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoSuchMethodError when following FetchOnlineDataExample #600

Open
benjaminaaron opened this issue Jul 3, 2021 · 41 comments · Fixed by #694
Open

NoSuchMethodError when following FetchOnlineDataExample #600

benjaminaaron opened this issue Jul 3, 2021 · 41 comments · Fixed by #694

Comments

@benjaminaaron
Copy link

benjaminaaron commented Jul 3, 2021

I am using exactly the code from FetchOnlineDataExample.java (from here) and nothing else:

public static void main(String[] args) {
    WikibaseDataFetcher wbdf = new WikibaseDataFetcher(
        BasicApiConnection.getWikidataApiConnection(),
        Datamodel.SITE_WIKIDATA);
    try {
        EntityDocument q42 = wbdf.getEntityDocument("Q42");
        System.out.println(q42);
    } catch (MediaWikiApiErrorException | IOException e) {
        e.printStackTrace();
    }
}

And get this error:

Exception in thread "main" java.lang.NoSuchMethodError: 'okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType)'
	at org.wikidata.wdtk.wikibaseapi.ApiConnection.sendRequest(ApiConnection.java:396)
	at org.wikidata.wdtk.wikibaseapi.ApiConnection.sendJsonRequest(ApiConnection.java:364)
	at org.wikidata.wdtk.wikibaseapi.WbGetEntitiesAction.wbGetEntities(WbGetEntitiesAction.java:202)
	at org.wikidata.wdtk.wikibaseapi.WbGetEntitiesAction.wbGetEntities(WbGetEntitiesAction.java:108)
	at org.wikidata.wdtk.wikibaseapi.WikibaseDataFetcher.getEntityDocumentMap(WikibaseDataFetcher.java:404)
	at org.wikidata.wdtk.wikibaseapi.WikibaseDataFetcher.getEntityDocuments(WikibaseDataFetcher.java:187)
	at org.wikidata.wdtk.wikibaseapi.WikibaseDataFetcher.getEntityDocuments(WikibaseDataFetcher.java:156)
	at org.wikidata.wdtk.wikibaseapi.WikibaseDataFetcher.getEntityDocument(WikibaseDataFetcher.java:138)

I have this in my pom.xml:

<!-- https://mvnrepository.com/artifact/org.wikidata.wdtk/wdtk-wikibaseapi -->
<dependency>
   <groupId>org.wikidata.wdtk</groupId>
   <artifactId>wdtk-wikibaseapi</artifactId>
   <version>0.12.1</version>
</dependency>
@benjaminaaron benjaminaaron changed the title NoSuchMethodError when following FetchOnlineDataExample.java NoSuchMethodError when following FetchOnlineDataExample Jul 3, 2021
@benjaminaaron
Copy link
Author

It seems the parameters to pass to RequestBody.create() are in the wrong oder:

Screenshot 2021-07-03 at 18 37 21

@wetneb
Copy link
Member

wetneb commented Jul 3, 2021

Could this be a conflict between WDTK's OkHTTP and your OkHTTP? Maybe two different versions of the library are in the classpath? You could perhaps find out with mvn dependency:analyze (or dependencies:analyze, I cannot remember)

@benjaminaaron
Copy link
Author

Good idea @wetneb, thanks. I am not sure if the correct OkHTTP version gets used in my case. When I run mvn dependency:tree I get:

[INFO] \- org.wikidata.wdtk:wdtk-wikibaseapi:jar:0.12.1:compile
[INFO]    +- org.wikidata.wdtk:wdtk-datamodel:jar:0.12.1:compile
[INFO]    |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.12.3:compile
[INFO]    |  \- org.threeten:threeten-extra:jar:1.6.0:compile
[INFO]    +- org.wikidata.wdtk:wdtk-util:jar:0.12.1:compile
[INFO]    +- com.squareup.okhttp3:okhttp-urlconnection:jar:3.14.9:compile
[INFO]    |  \- com.squareup.okhttp3:okhttp:jar:3.14.9:compile
[INFO]    |     \- com.squareup.okio:okio:jar:1.17.2:compile
[INFO]    +- se.akerfeldt:okhttp-signpost:jar:1.1.0:compile
[INFO]    |  \- oauth.signpost:signpost-core:jar:1.2.1.2:compile
[INFO]    \- org.apache.commons:commons-lang3:jar:3.12.0:compil

And the OkHTTP version 3.14.9 that is listed there, is also the one my IDE is pointing to as can be seen on the far right side of the popup window in the screenshot above.
However, when I run the command you suggested, mvn dependency:analyze, I get:

[WARNING] Used undeclared dependencies found:
[WARNING]    com.squareup.okhttp3:okhttp:jar:3.14.9:compile

Not sure how to interpret this 🤔

In the pom.xml of this repository here it says:

Wikidata-Toolkit/pom.xml

Lines 85 to 86 in 58d6de3

<okhttpSignpostVersion>1.1.0</okhttpSignpostVersion>
<okhttpVersion>5.0.0-alpha.2</okhttpVersion>

Should I be expecting OkHTTP version 5.0.0-alpha.2 to be used instead of 3.4.9?

@benjaminaaron
Copy link
Author

benjaminaaron commented Jul 4, 2021

When I remove the wdtk-wikibaseapi dependency from my pom.xml, these two external libraries vanish:

com.squareup.okhttp3:okhttp:3.14.9
com.squareup.okhttp3:okhttp-urlconnection:3.14.9

So no other dependency of mine is using them. I also removed the squareup folder in ~/.m2 to make sure its not a caching issue. Once I add the wdtk-wikibaseapi dependency again, the same versions get added as external libraries.

@wetneb
Copy link
Member

wetneb commented Jul 4, 2021

The pom.xml file in this repository is for the development version of WDTK, it is normal that versions of WDTK released in the past use other versions of this dependency.
So the issue probably comes from somewhere else…

@benjaminaaron
Copy link
Author

My solution for now is to have a public class FixedBasicApiConnection extends BasicApiConnection that overrides sendRequest() and passes the parameters in swapped order to RequestBody.create(), then it works. If this is actually a general bug and not something local for me, I'd be happy to make a PR that swaps the parameters in ApiConnection.

@Lhaaits
Copy link
Collaborator

Lhaaits commented Jun 15, 2022

I ran into the same exact problem just now. The only okhttp dependency in my tree comes from the wbtk-wikibaseapi:

[INFO] |  +- org.wikidata.wdtk:wdtk-util:jar:0.13.3:compile
[INFO] |  |  \- org.apache.commons:commons-compress:jar:1.21:compile
[INFO] |  +- com.squareup.okhttp3:okhttp-urlconnection:jar:3.14.9:compile
[INFO] |  |  \- com.squareup.okhttp3:okhttp:jar:3.14.9:compile
[INFO] |  |     \- com.squareup.okio:okio:jar:1.17.2:compile
[INFO] |  \- se.akerfeldt:okhttp-signpost:jar:1.1.0:compile
[INFO] |     \- oauth.signpost:signpost-core:jar:1.2.1.2:compile

@wetneb
Copy link
Member

wetneb commented Jun 15, 2022

Ok, so in OpenRefine it works, and there we manually pin to okhttp 4.9.3. So let me just publish a new minor release with that dependency. We can then investigate why this is not even picked up at compilation time or in the tests. Very weird!

@wetneb
Copy link
Member

wetneb commented Jun 15, 2022

Ok, we actually pull in two different versions of OkHTTP as dependencies of WDTK at the moment, hence the mess. Let me clean that up.

wetneb added a commit that referenced this issue Jun 16, 2022
Upgrading to JUnit5 requires upgrading OkHTTP to a newer version, but our okhttp-signpost
dependency still relies on an earlier version.

This closes #600.

This reverts commit 522abd4.
wetneb added a commit that referenced this issue Jun 16, 2022
Upgrading to JUnit5 requires upgrading OkHTTP to a newer version, but our okhttp-signpost
dependency still relies on an earlier version.

This closes #600.

This reverts commit 522abd4.
@Lhaaits
Copy link
Collaborator

Lhaaits commented Jun 29, 2022

What's the status of this bug? I guess it's related to reverting 536?

@robertvazan
Copy link
Collaborator

How about merging #698? It looks like it contains a fix. If not, there's still the exclusions workaround I mentioned in #694. Downgrading to stable okhttp requires a bit more work.

@Lhaaits
Copy link
Collaborator

Lhaaits commented Jun 29, 2022

I'm kind of confused what I would need to exclude. I'm only using the wdtk-wikibaseapi. Not sure where okhttp 5 would be coming from...

<dependency>
    <groupId>org.wikidata.wdtk</groupId>
    <artifactId>wdtk-wikibaseapi</artifactId>
    <version>0.13.3</version>
</dependency>

@robertvazan
Copy link
Collaborator

Try this (untested):

<dependency>
    <groupId>org.wikidata.wdtk</groupId>
    <artifactId>wdtk-wikibaseapi</artifactId>
    <version>0.13.3</version>
    <exclusions>
        <exclusion>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
        </exclusion>
    </exclusions> 
</dependency>

If you have other dependencies that pull in okhttp, you need to do the same for them.

@Lhaaits
Copy link
Collaborator

Lhaaits commented Jun 29, 2022

I tried this, but this just caused my project to miss okhttpClient. I think the quickest fix is to switch the RequestBody.create(.. arguments on line 447 of ApiConnection, though I do wonder why this does not cause a problem for everyone, as ApiConnection imports okhttp3.RequestBody
The FixedBasicApiConnection workaround works, but feels very hacky.

@wetneb
Copy link
Member

wetneb commented Jun 29, 2022

Fine with me to try upgrading OkHTTP (but I am not sure why you think downgrading to stable would be more work - is there anything else to do beyond #694?)

@robertvazan
Copy link
Collaborator

@Lhaaits I will have to test this on my own app

@wetneb Mockwebserver alternative is a lot of work. Merging #694 makes it harder, because junit5 upgrade would have to be reapplied after it. I had to give my attention to two other opensource projects, so I am only getting around to this now.

@wetneb
Copy link
Member

wetneb commented Jun 29, 2022

As you prefer! Let me merge #698 and make a patch release so that people can test it more easily.

@wetneb
Copy link
Member

wetneb commented Jul 1, 2022

hey @Lhaaits, we just released a new version which could potentially solve this, can you check on your side if it works for you?

@Lhaaits
Copy link
Collaborator

Lhaaits commented Jul 1, 2022

0.13.4?
Still same exception:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.wikidata.wdtk.wikibaseapi.ApiConnection.sendRequest(ApiConnection.java:447)

The following method did not exist:

    'okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType)'

The calling method's class, org.wikidata.wdtk.wikibaseapi.ApiConnection, was loaded from the following location:

    jar:file:/Users/admin/.m2/repository/org/wikidata/wdtk/wdtk-wikibaseapi/0.13.4/wdtk-wikibaseapi-0.13.4.jar!/org/wikidata/wdtk/wikibaseapi/ApiConnection.class

@wetneb
Copy link
Member

wetneb commented Jul 1, 2022

Thanks!

@robertvazan my offer to downgrade to stable okhttp still stands. I understand you do not like it because it downgrades Junit but it feels pretty important to me to solve this quickly. I will personally not have the time to embark on a big change of our testing architecture (by adding a dockerized Wikibase or by developing our own Wikibase-like server).

@robertvazan
Copy link
Collaborator

@wetneb I cannot work on this immediately, because I have one other OSS project still in need of my attention. I might need a week or more to get this done. If the quick fix I offered before does not work and the issue is urgent, feel free to downgrade okhttp for now. If I find a way to do it better by replacing mockwebserver, I will begin my PR with reapplication of junit upgrade, so that the junit5 work is not lost.

@wetneb
Copy link
Member

wetneb commented Jul 1, 2022

That sounds like a great plan!

wetneb added a commit that referenced this issue Jul 1, 2022
Upgrading to JUnit5 requires upgrading OkHTTP to a newer version, but our okhttp-signpost
dependency still relies on an earlier version.

This closes #600.

This reverts commit 522abd4.
@wetneb
Copy link
Member

wetneb commented Jul 2, 2022

@Lhaaits how about 0.13.5?

@Lhaaits
Copy link
Collaborator

Lhaaits commented Jul 4, 2022

Still the same problem :/

@Lhaaits
Copy link
Collaborator

Lhaaits commented Jul 4, 2022

[INFO] Scanning for projects...
[INFO] 
[INFO] --------------------------< nl.kb.kbga:emma >---------------------------
[INFO] Building EMMA 0.0.4-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:3.2.0:tree (default-cli) @ emma ---
[INFO] nl.kb.kbga:emma:jar:0.0.4-SNAPSHOT
[INFO] +- nl.kbif.leibniz.commons:leibniz-auth:jar:5.0.0:compile
[INFO] |  +- nl.kbif.leibniz.commons:leibniz-spring:jar:5.0.0:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-validation:jar:2.6.6:compile
[INFO] |  |  |  \- org.hibernate.validator:hibernate-validator:jar:6.2.3.Final:compile
[INFO] |  |  |     +- jakarta.validation:jakarta.validation-api:jar:2.0.2:compile
[INFO] |  |  |     +- org.jboss.logging:jboss-logging:jar:3.4.3.Final:compile
[INFO] |  |  |     \- com.fasterxml:classmate:jar:1.5.1:compile
[INFO] |  |  \- org.springframework.boot:spring-boot-actuator:jar:2.6.6:compile
[INFO] |  \- org.springframework.boot:spring-boot-starter-security:jar:2.6.6:compile
[INFO] |     +- org.springframework:spring-aop:jar:5.3.18:compile
[INFO] |     +- org.springframework.security:spring-security-config:jar:5.6.2:compile
[INFO] |     |  \- org.springframework.security:spring-security-core:jar:5.6.2:compile
[INFO] |     \- org.springframework.security:spring-security-web:jar:5.6.2:compile
[INFO] +- nl.kbif.leibniz.commons:leibniz-commons:jar:5.0.0:compile
[INFO] |  +- org.springframework:spring-web:jar:5.3.18:compile
[INFO] |  |  \- org.springframework:spring-beans:jar:5.3.18:compile
[INFO] |  +- org.springframework:spring-jdbc:jar:5.3.18:compile
[INFO] |  |  \- org.springframework:spring-tx:jar:5.3.18:compile
[INFO] |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:jar:2.13.2:compile
[INFO] |  |  +- com.fasterxml.jackson.core:jackson-core:jar:2.13.2:compile
[INFO] |  |  +- org.codehaus.woodstox:stax2-api:jar:4.2.1:compile
[INFO] |  |  \- com.fasterxml.woodstox:woodstox-core:jar:6.2.7:compile
[INFO] |  +- org.slf4j:slf4j-api:jar:1.7.36:compile
[INFO] |  +- org.apache.commons:commons-lang3:jar:3.12.0:compile
[INFO] |  \- net.sf.saxon:Saxon-HE:jar:10.3:compile
[INFO] +- org.liquibase:liquibase-core:jar:4.11.0:runtime
[INFO] |  \- javax.xml.bind:jaxb-api:jar:2.3.1:runtime
[INFO] |     \- javax.activation:javax.activation-api:jar:1.2.0:runtime
[INFO] +- org.postgresql:postgresql:jar:42.3.6:runtime
[INFO] |  \- org.checkerframework:checker-qual:jar:3.5.0:runtime
[INFO] +- org.projectlombok:lombok:jar:1.18.24:provided
[INFO] +- org.springframework.boot:spring-boot-configuration-processor:jar:2.7.0:compile (optional) 
[INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:2.7.0:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter:jar:2.6.6:compile
[INFO] |  |  +- org.springframework.boot:spring-boot:jar:2.6.6:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.6.6:compile
[INFO] |  |  |  +- ch.qos.logback:logback-classic:jar:1.2.11:compile
[INFO] |  |  |  |  \- ch.qos.logback:logback-core:jar:1.2.11:compile
[INFO] |  |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.17.2:compile
[INFO] |  |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.17.2:compile
[INFO] |  |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.36:compile
[INFO] |  |  +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
[INFO] |  |  \- org.yaml:snakeyaml:jar:1.29:compile
[INFO] |  +- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:2.6.6:compile
[INFO] |  |  \- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.2:compile
[INFO] |  \- io.micrometer:micrometer-core:jar:1.8.4:compile
[INFO] |     +- org.hdrhistogram:HdrHistogram:jar:2.1.12:compile
[INFO] |     \- org.latencyutils:LatencyUtils:jar:2.0.3:runtime
[INFO] +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.7.0:compile
[INFO] |  \- com.zaxxer:HikariCP:jar:4.0.3:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.7.0:test
[INFO] |  +- org.springframework.boot:spring-boot-test:jar:2.6.6:test
[INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.6.6:test
[INFO] |  +- com.jayway.jsonpath:json-path:jar:2.6.0:test
[INFO] |  |  \- net.minidev:json-smart:jar:2.4.8:test
[INFO] |  |     \- net.minidev:accessors-smart:jar:2.4.8:test
[INFO] |  |        \- org.ow2.asm:asm:jar:9.1:test
[INFO] |  +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:test
[INFO] |  |  \- jakarta.activation:jakarta.activation-api:jar:1.2.2:test
[INFO] |  +- org.assertj:assertj-core:jar:3.21.0:test
[INFO] |  +- org.hamcrest:hamcrest:jar:2.2:test
[INFO] |  +- org.junit.jupiter:junit-jupiter:jar:5.8.2:test
[INFO] |  |  +- org.junit.jupiter:junit-jupiter-api:jar:5.8.2:test
[INFO] |  |  |  +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] |  |  |  +- org.junit.platform:junit-platform-commons:jar:1.8.2:test
[INFO] |  |  |  \- org.apiguardian:apiguardian-api:jar:1.1.2:test
[INFO] |  |  +- org.junit.jupiter:junit-jupiter-params:jar:5.8.2:test
[INFO] |  |  \- org.junit.jupiter:junit-jupiter-engine:jar:5.8.2:test
[INFO] |  |     \- org.junit.platform:junit-platform-engine:jar:1.8.2:test
[INFO] |  +- org.mockito:mockito-core:jar:4.0.0:test
[INFO] |  |  +- net.bytebuddy:byte-buddy:jar:1.11.22:test
[INFO] |  |  +- net.bytebuddy:byte-buddy-agent:jar:1.11.22:test
[INFO] |  |  \- org.objenesis:objenesis:jar:3.2:test
[INFO] |  +- org.mockito:mockito-junit-jupiter:jar:4.0.0:test
[INFO] |  +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO] |  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] |  +- org.springframework:spring-core:jar:5.3.18:compile
[INFO] |  |  \- org.springframework:spring-jcl:jar:5.3.18:compile
[INFO] |  +- org.springframework:spring-test:jar:5.3.18:test
[INFO] |  \- org.xmlunit:xmlunit-core:jar:2.8.4:test
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.7.0:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-json:jar:2.6.6:compile
[INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.13.2:compile
[INFO] |  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.13.2:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.6.6:compile
[INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.60:compile
[INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.60:compile
[INFO] |  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.60:compile
[INFO] |  \- org.springframework:spring-webmvc:jar:5.3.18:compile
[INFO] |     +- org.springframework:spring-context:jar:5.3.18:compile
[INFO] |     \- org.springframework:spring-expression:jar:5.3.18:compile
[INFO] +- org.springframework.cloud:spring-cloud-config-client:jar:3.1.3:compile
[INFO] |  +- org.springframework.boot:spring-boot-autoconfigure:jar:2.6.6:compile
[INFO] |  +- org.springframework.cloud:spring-cloud-commons:jar:3.1.2:compile
[INFO] |  |  \- org.springframework.security:spring-security-crypto:jar:5.6.2:compile
[INFO] |  +- org.springframework.cloud:spring-cloud-context:jar:3.1.2:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.13.2:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.13.2.2:compile
[INFO] |  \- org.apache.httpcomponents:httpclient:jar:4.5.13:compile
[INFO] |     +- org.apache.httpcomponents:httpcore:jar:4.4.15:compile
[INFO] |     \- commons-codec:commons-codec:jar:1.15:compile
[INFO] +- org.springframework.cloud:spring-cloud-starter-bootstrap:jar:3.1.3:compile
[INFO] |  \- org.springframework.cloud:spring-cloud-starter:jar:3.1.2:compile
[INFO] |     \- org.springframework.security:spring-security-rsa:jar:1.0.10.RELEASE:compile
[INFO] |        \- org.bouncycastle:bcpkix-jdk15on:jar:1.68:compile
[INFO] |           \- org.bouncycastle:bcprov-jdk15on:jar:1.68:compile
[INFO] +- org.testcontainers:postgresql:jar:1.17.2:test
[INFO] |  \- org.testcontainers:jdbc:jar:1.17.2:test
[INFO] |     \- org.testcontainers:database-commons:jar:1.17.2:test
[INFO] |        \- org.testcontainers:testcontainers:jar:1.17.2:test
[INFO] |           +- junit:junit:jar:4.13.2:test
[INFO] |           |  \- org.hamcrest:hamcrest-core:jar:2.2:test
[INFO] |           +- org.rnorth.duct-tape:duct-tape:jar:1.0.8:test
[INFO] |           |  \- org.jetbrains:annotations:jar:17.0.0:test
[INFO] |           +- com.github.docker-java:docker-java-api:jar:3.2.13:test
[INFO] |           \- com.github.docker-java:docker-java-transport-zerodep:jar:3.2.13:test
[INFO] |              +- com.github.docker-java:docker-java-transport:jar:3.2.13:test
[INFO] |              \- net.java.dev.jna:jna:jar:5.8.0:test
[INFO] \- org.wikidata.wdtk:wdtk-wikibaseapi:jar:0.13.5:compile
[INFO]    +- org.wikidata.wdtk:wdtk-datamodel:jar:0.13.5:compile
[INFO]    |  \- org.threeten:threeten-extra:jar:1.7.0:compile
[INFO]    +- org.wikidata.wdtk:wdtk-util:jar:0.13.5:compile
[INFO]    |  \- org.apache.commons:commons-compress:jar:1.21:compile
[INFO]    +- com.squareup.okhttp3:okhttp-urlconnection:jar:3.14.9:compile
[INFO]    |  \- com.squareup.okhttp3:okhttp:jar:3.14.9:compile
[INFO]    |     \- com.squareup.okio:okio:jar:1.17.2:compile
[INFO]    \- se.akerfeldt:okhttp-signpost:jar:1.1.0:compile
[INFO]       \- oauth.signpost:signpost-core:jar:1.2.1.2:compile
[INFO] ------------------------------------------------------------------------

@Lhaaits
Copy link
Collaborator

Lhaaits commented Jul 4, 2022

3.14.9 is the only version of okhttp being imported. Still not sure why RequestBody.create in BasicApiConnection is expecting java.lang.String, okhttp3.MediaType

@wetneb
Copy link
Member

wetneb commented Jul 4, 2022

Hmmm, I am not sure where "3.14.9" is coming from. This new version of WDTK depends on OkHTTP 4.2.2. Could you try adding an explicit dependency to com.squareup.okhttp3:okhttp-urlconnection:4.2.2 in your POM?

@wetneb wetneb reopened this Jul 4, 2022
@Lhaaits
Copy link
Collaborator

Lhaaits commented Jul 4, 2022

image

@Lhaaits
Copy link
Collaborator

Lhaaits commented Jul 4, 2022

Still uses okhttp:3.14.9, and still gives the error. I'll also try to get it to work locally and maybe make a pull request.
I also tried 'invalidate cache' in IntelliJ and mvn clean install -U, but no luck...

@robertvazan
Copy link
Collaborator

@Lhaaits Did you remove the exclusion rule from your POM?

@Lhaaits
Copy link
Collaborator

Lhaaits commented Jul 4, 2022

I tried with and without exclusion rule for both okhttp-urlconnection and okhttp. In all cases it's still giving the same error.
In the fork I made locally of wdtk master branch I also got the same error btw.
edit: nvm I had to fetch the upstream branch. So locally the fork is not giving the error anymore. But 0.13.5 still is... Strange

@Lhaaits
Copy link
Collaborator

Lhaaits commented Jul 4, 2022

Okay so if I checkout commit 453eaf2 (the 0.13.5 commit) IntelliJ is saying that the 4.2.2 version of okhttp is conflicting with the 3.0.0-rc1 version, which comes from okhttp-signpost:1.1.0. Maybe when I'm using the 0.13.5 version in my application for some reason maven decides to use the 3.0.0-RC1 version, while wikibaseapi uses the 4.2.2 version?

@Lhaaits
Copy link
Collaborator

Lhaaits commented Jul 4, 2022

It's weird how the underlying dependencies my application seems to be importing are different from the ones wdtk-api is importing, for the same base version

@Lhaaits
Copy link
Collaborator

Lhaaits commented Jul 4, 2022

This is my application:
image

@Lhaaits
Copy link
Collaborator

Lhaaits commented Jul 4, 2022

This is the wikidata-toolkit fork:
image

@wetneb
Copy link
Member

wetneb commented Jul 4, 2022

From your last screenshot, it looks like you are indeed using okhttp 4.2.2. Could it be that you have left the previous workaround in place (the FixedBasicApiConnection suggested above, or a similar one), meaning that the arguments are not in the order expected by okhttp 4.2.2?

@Lhaaits
Copy link
Collaborator

Lhaaits commented Jul 4, 2022

I'm using BasicApiConnection to test the fixes. The top screenshot is my application, which for some reason won't use 4.2.2. Even after adding com.squareup.okhttp3:okhttp-urlconnection:4.2.2 to my pom:
image

@wetneb
Copy link
Member

wetneb commented Jul 4, 2022

I would try adding an explicit dependency to com.squareup.okhttp3:okhttp:4.2.2 as well.
Also I would be curious what you get with a grep -RP "3\.14\.9" . in your project workspace (and potentially maven cache?) which could lead you to the place where this version is mentioned?

@Lhaaits
Copy link
Collaborator

Lhaaits commented Jul 4, 2022

Also adding com.squareup.okhttp3:okhttp:4.2.2 seems to work! I hadn't tried to add both okhttp-urlconnection and okhttp next to wdtk-wikibaseapi. Thanks!

@robertvazan
Copy link
Collaborator

@wetneb Aren't we missing okhttp 4.x dependency in wikibaseapi module? It could spare downstream projects of the need to declare the dependency in their own POM.

@wetneb
Copy link
Member

wetneb commented Jul 4, 2022

It sounds like a sensible move given @Lhaaits's experience indeed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants