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

Including in Spring Boot project #582

Closed
gboersma opened this issue Jul 23, 2021 · 3 comments · Fixed by #589
Closed

Including in Spring Boot project #582

gboersma opened this issue Jul 23, 2021 · 3 comments · Fixed by #589
Assignees
Labels
kind/bug Something isn't working
Milestone

Comments

@gboersma
Copy link

Including the java-sdk as a dependency for a Spring Boot project builds properly, but results in a "NoSuchMethodError: Companion" exception at run-time when initializing an instance of the DaprHttp.

From investigation, it appears that this has to do with the okhttp library and version mismatches:

Without Spring Boot:

[INFO]    \- com.squareup.okhttp3:okhttp:jar:4.9.0:compile
[INFO]       +- com.squareup.okio:okio:jar:2.8.0:compile
[INFO]       |  \- org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.4.0:compile
[INFO]       \- org.jetbrains.kotlin:kotlin-stdlib:jar:1.4.10:compile
[INFO]          \- org.jetbrains:annotations:jar:13.0:compile

With Spring Boot:

[INFO]    \- com.squareup.okhttp3:okhttp:jar:3.14.9:compile
[INFO]       \- com.squareup.okio:okio:jar:1.17.2:compile

Adding this explicit dependency to the POM fixed the problem:

        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>4.9.0</version>
        </dependency>

I am scratching my head why this happens since a standalone Spring Boot project does not include the okhttp library, so I am not sure why a Spring Boot + Java SDK project would downgrade this dependency, and I was unable to determine it using the Maven dependency tool.

Referencing the dependency explicitly does fix the problem. Two asks:

  1. Investigate if there is a better way to resolve this issue.
  2. Add a note to the README to help others avoid this issue.
@gboersma gboersma added the kind/bug Something isn't working label Jul 23, 2021
@mthmulders
Copy link
Contributor

Duplicate of #515. You can work-around this by changing the Spring Boot version to one that uses a compatible OkHTTP version, or force a compatible OkHttp version in your project by adding the following dependency:

    <dependency>
      <groupId>com.squareup.okhttp3</groupId>
      <artifactId>okhttp</artifactId>
      <version>4.9.0</version>
    </dependency>

@artursouza
Copy link
Member

We had a note on this in the README.md file. Please, add it again.

@mthmulders
Copy link
Contributor

To add a bit more detail regarding your first question: I believe the OkHttp dependency that you see when you do have Spring Boot is "managed" by the Spring Boot "Bill of Materials".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants