Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I resolve "error: bad symbolic reference" for dependencies using maven-scala plugin?

Tags:

maven

scala

slick

I'm building a small database query utility using Scala and Slick, with Maven as my build and packaging tool.

My code compiles without any syntax errors, but the build fails with this:

[INFO] --- maven-scala-plugin:2.15.0:compile (default) @ origdups ---
[INFO] Checking for multiple versions of scala
[INFO] includes = [**/*.scala,**/*.java,]
[INFO] excludes = []
[INFO] /home/lreeder/dev/scala/origdups/src/main/scala:-1: info: compiling
[INFO] Compiling 4 source files to /home/lreeder/dev/scala/origdups/target/classes at 1375638972068
[INFO] No known dependencies. Compiling everything
[ERROR] error: bad symbolic reference. A signature in Mapper.class refers to term runtime
[INFO] in package scala.reflect which is not available.
[INFO] It may be completely missing from the current classpath, or the version on
[INFO] the classpath might be incompatible with the version used when compiling Mapper.class.
(several more similar errors)

Note that the Mapper class is not my code. I think it's part of Slick? I'm using Scala 2.10.1 for the maven-scala plugin:

<dependency>
  <groupId>org.scala-lang</groupId>
  <artifactId>scala-library</artifactId>
  <version>2.10.1</version>
</dependency>

and Slick 2.10 (currently build with Scala 2.10.1):

<dependency>
   <groupId>com.typesafe.slick</groupId>
   <artifactId>slick_2.10</artifactId>
   <version>1.0.1</version>
</dependency>

I've compiled with maven debug turned on, and this is the Java call that generates the errors above.

/usr/local/jdk1.7.0_21/jre/bin/java -classpath /home/lreeder/.m2/repository/org/scala-lang/scala-library/2.10.1/scala-library-2.10.1.jar:/home/lreeder/.m2/repository/org/scala-lang/scala-compiler/2.10.1/scala-compiler-2.10.1.jar:/home/lreeder/.m2/repository/org/scala-lang/scala-reflect/2.10.1/scala-reflect-2.10.1.jar:/home/lreeder/.m2/repository/org/scala-tools/maven-scala-plugin/2.15.0/maven-scala-plugin-2.15.0.jar -Xbootclasspath/a:/home/lreeder/.m2/repository/org/scala-lang/scala-library/2.10.1/scala-library-2.10.1.jar org_scala_tools_maven_executions.MainWithArgsInFile scala.tools.nsc.Main /tmp/scala-maven-6314934214401019063.args

What am I missing here? What needs to be set in the maven-scala plugin configuration to get rid of these errors.

like image 715
lreeder Avatar asked Aug 04 '13 18:08

lreeder


1 Answers

This error:

error: bad symbolic reference. A signature in Mapper.class refers to term runtime in package scala.reflect which is not available.

is saying that scala.reflect.runtime is missing from the classpath. And, indeed, upon checking /tmp/scala-maven-6314934214401019063.args, it was not in the classpaths listed there.

Slick 2.10 has dependencies on the Scala reflection package. See https://github.com/slick/slick/blob/master/src/main/scala/scala/slick/direct/MetadataProvider.scala. So, the POM for Slick should list scala-reflect so that other projects can resolve it as a transitive dependency. However, slick_2.10-1.0.1.pom does not list scala-reflect.

Adding scala-reflect as a dependency in my own project POM fixed this.

like image 137
lreeder Avatar answered Nov 18 '22 12:11

lreeder