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

Javalin fails on JPMS with module io.javalin does not declare uses #2136

Closed
SentryMan opened this issue Feb 24, 2024 · 0 comments · Fixed by #2137
Closed

Javalin fails on JPMS with module io.javalin does not declare uses #2136

SentryMan opened this issue Feb 24, 2024 · 0 comments · Fixed by #2137

Comments

@SentryMan
Copy link
Contributor

SentryMan commented Feb 24, 2024

Actual behavior (the bug)
When running javalin using JPMS or Jlinked images, I get this error

Exception in thread "main" java.util.ServiceConfigurationError: org.slf4j.spi.SLF4JServiceProvider: module io.javalin does not declare `uses`
        at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:593)
        at java.base/java.util.ServiceLoader.checkCaller(ServiceLoader.java:579)
        at java.base/java.util.ServiceLoader.<init>(ServiceLoader.java:507)
        at java.base/java.util.ServiceLoader.load(ServiceLoader.java:1698)
        at io.javalin@6.1.1/io.javalin.util.Util.slf4jServiceImplementationExists(Util.kt:45)
        at io.javalin@6.1.1/io.javalin.util.Util.printHelpfulMessageIfLoggerIsMissing(Util.kt:53)
        at io.javalin@6.1.1/io.javalin.jetty.JettyServer.start(JettyServer.kt:64)
        at io.javalin@6.1.1/io.javalin.Javalin.start(Javalin.java:123)
        at avaje.javalin.example@1.0.0-SNAPSHOT/com.jojo.javalin.api.JavalinAPI.main(JavalinAPI.java:15)

It seems that

private fun slf4jServiceImplementationExists() = try {
val serviceClass = Class.forName("org.slf4j.spi.SLF4JServiceProvider")
val loader = ServiceLoader.load(serviceClass)
loader.any()
} catch (e: ClassNotFoundException) {
false
}
is the cause as the corresponding uses org.slf4j.spi.SLF4JServiceProvider statement in the module-info appears to have been removed.

Expected behavior
The application doesn't die.

To Reproduce

  1. clone this repo
  2. checkout the jlink branch
  3. execute the run.sh or the runJlinked.sh script
SentryMan added a commit to SentryMan/javalin that referenced this issue Feb 24, 2024
tipsy pushed a commit that referenced this issue Feb 24, 2024
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.

1 participant