Skip to content

Including in Spring Boot project #582

@gboersma

Description

@gboersma

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.

Metadata

Metadata

Assignees

Labels

kind/bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions