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

Sttp client failing with Java 8 #11

Open
Andrapyre opened this issue Nov 21, 2024 · 3 comments
Open

Sttp client failing with Java 8 #11

Andrapyre opened this issue Nov 21, 2024 · 3 comments

Comments

@Andrapyre
Copy link
Contributor

Andrapyre commented Nov 21, 2024

Description

When the sttp client runs with Java 8, it produces the following error in Github Actions on all Scala versions:

java.lang.UnsupportedClassVersionError: sttp/client4/httpurlconnection/HttpURLConnectionBackend$ has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

First raised in xerial/sbt-sonatype#548

@Andrapyre
Copy link
Contributor Author

Refactoring to change to an OkHttp backend produces the following:

com.lumidion.sonatype.central.client.integration.test.SyncSttpItSpec *** ABORTED ***
[info]   java.lang.NoClassDefFoundError: java/net/http/HttpTimeoutException
[info]   at sttp.client4.okhttp.OkHttpBackend.adjustExceptions(OkHttpBackend.scala:49)
[info]   at sttp.client4.okhttp.OkHttpBackend.send(OkHttpBackend.scala:38)
[info]   at sttp.client4.wrappers.FollowRedirectsBackend.sendWithCounter(FollowRedirectsBackend.scala:19)
[info]   at sttp.client4.wrappers.FollowRedirectsBackend.send(FollowRedirectsBackend.scala:15)
[info]   at sttp.client4.Request.send(request.scala:159)
[info]   at com.lumidion.sonatype.central.client.sttp.core.SyncSonatypeClient.uploadBundle(SyncSonatypeClient.scala:27)
[info]   at com.lumidion.sonatype.central.client.integration.test.SyncSttpItSpec.$anonfun$new$7(SyncSttpItSpec.scala:42)
[info]   at org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85)
[info]   at org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:83)
[info]   at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
[info]   ...
[info]   Cause: java.lang.ClassNotFoundException: java.net.http.HttpTimeoutException
[info]   at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
[info]   at sbt.internal.ManagedClassLoader.findClass(ManagedClassLoader.java:103)
[info]   at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
[info]   at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
[info]   at sttp.client4.okhttp.OkHttpBackend.adjustExceptions(OkHttpBackend.scala:49)
[info]   at sttp.client4.okhttp.OkHttpBackend.send(OkHttpBackend.scala:38)
[info]   at sttp.client4.wrappers.FollowRedirectsBackend.sendWithCounter(FollowRedirectsBackend.scala:19)
[info]   at sttp.client4.wrappers.FollowRedirectsBackend.send(FollowRedirectsBackend.scala:15)
[info]   at sttp.client4.Request.send(request.scala:159)
[info]   at com.lumidion.sonatype.central.client.sttp.core.SyncSonatypeClient.uploadBundle(SyncSonatypeClient.scala:27)

@Andrapyre
Copy link
Contributor Author

@adamw, replying to your comment, this actions run produces the following results for Java 8:

  • Scala 2.12 - java.lang.NoClassDefFoundError: java/net/http/HttpTimeoutException
  • Scala 2.13 and 3.3.3 - java.lang.UnsupportedClassVersionError: sttp/client4/SyncBackend has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

This is after I refactored the HttpURLConnectionBackend to remove any direct or downstream calls (like this) to classes that are Java 11+ (see branch).

It must be that the httpclient package in the sttp core module is forcing Java 11+ for the whole package. The httpclient package would probably need to be removed from core and put in its own module and the build machine reverted to Java 8 for when non-httpclient libs are published, if you want to support Java 8 at all, that is.

From your responses, it seems like you haven't worked with Java 8 in a while and you don't get this complaint very often (it's been years since I worked with Java 8 myself), so there is probably not enough demand to justify these breaking changes. But maybe worth putting a note in the readme that users need Java 11+ to work with sttp.

@adamw
Copy link

adamw commented Nov 27, 2024

@Andrapyre the main documentation page (https://sttp.softwaremill.com/en/latest/) specifies that: upported Java versions include 11+.

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

No branches or pull requests

2 participants