abergmeier
abergmeier

Reputation: 14052

Missing Logger in classpath

I try to compile a Scala library in Bazel. This leads to an error:

error: Symbol 'type <none>.slf4j.Logger' is missing from the classpath.
This symbol is required by 'value com.typesafe.scalalogging.slf4j.Logger.underlying'.
Make sure that type Logger is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
A full rebuild may help if 'Logger.class' was compiled against an incompatible version of <none>.slf4j.
      logger.warn("Foo")
      ^
one error found
one error found
java.lang.RuntimeException: Build failed
    at io.bazel.rulesscala.scalac.ScalacProcessor.compileScalaSources(ScalacProcessor.java:256)
    at io.bazel.rulesscala.scalac.ScalacProcessor.processRequest(ScalacProcessor.java:76)
    at io.bazel.rulesscala.worker.GenericWorker.runPersistentWorker(GenericWorker.java:45)
    at io.bazel.rulesscala.worker.GenericWorker.run(GenericWorker.java:111)
    at io.bazel.rulesscala.scalac.ScalaCInvoker.main(ScalaCInvoker.java:41)

My BUILD.bazel looks like this:

load("@io_bazel_rules_scala//scala:scala.bzl", "scala_library")

scala_library(
    name = "foo",
    srcs = [
        "src/main/scala/Foo.scala",
    ],
    deps = [
        "@maven//:com_fasterxml_jackson_core_jackson_core",
        "@maven//:com_fasterxml_jackson_core_jackson_databind",
        "@maven//:com_fasterxml_jackson_module_jackson_module_scala_2_11",
        "@maven//:com_typesafe_scala_logging_scala_logging_api_2_11",
        "@maven//:com_typesafe_scala_logging_scala_logging_slf4j_2_11",
        "@maven//:joda_time_joda_time",
        "@maven//:org_scalaj_scalaj_http_2_11",
    ],
)

From what I have read this error usually stems from mixing 2.x and 2.y Scala versions. I cannot for the live of me figure out where I would do this, though.

Upvotes: 1

Views: 1748

Answers (1)

abergmeier
abergmeier

Reputation: 14052

Had to add org.sonarsource.sonarlint.core:sonarlint-slf4j-sonar-log:4.8.0.14729 as a dependency because it wants org.slf4j.Logger.

Had to look at the sourcecode to find this:

import org.slf4j.{ LoggerFactory, Marker, Logger => Underlying }

Upvotes: 1

Related Questions