18

When I tried to compile simple typesafe' akka program (scala 2.10, akka, 2.1.0):

 scalac -cp "akka-actor_2.10-2.1.0.jar:akka-camel_2.10-2.1.0.jar" write2.scala

error: bad symbolic reference. A signature in package.class refers to term apache
in package org which is not available.
It may be completely missing from the current classpath, or the version on
the classpath might be incompatible with the version used when compiling package.class.
error: bad symbolic reference. A signature in package.class refers to term camel
in value org.apache which is not available.
It may be completely missing from the current classpath, or the version on
the classpath might be incompatible with the version used when compiling package.class.
write2.scala:21: error: bad symbolic reference. A signature in package.class refers to term model
in value org.camel which is not available.
It may be completely missing from the current classpath, or the version on
the classpath might be incompatible with the version used when compiling package.class.
val mina = system.actorOf(Props[MyEndPoint])

three errors found

The code on line 21:

 val mina = system.actorOf(Props[MyEndPoint])

(The same program was compiled correctly in Eclipse, so the source code is OK)

Most likely some jar file is missing in -cp variable. The question is what mean that strange/useless error message.

Thanks, Tomas

xhudik
  • 2,414
  • 1
  • 21
  • 39
  • You have around a dozen jar files missing from your `-cp`: all the dependencies of akka-actor and akka-camel (and their dependencies, and so on...). I strongly recommend using a build tool like SBT to take care of those things. – gourlaysama Sep 10 '13 at 15:19

4 Answers4

11

The message says "There's no package org.apache in my classpath, and I need it while reading file package.class". Pass -Ylog-classpath to scalac and look at what is the real classpath that gets to the compiler.

Iulian Dragos
  • 5,692
  • 23
  • 31
  • 1
    @lulian Dragos so term "package.class" refers to my scala file which is actually being compiled? Sounds strange, just wondering why the message couldn't be clear and short as your explanation ("There's no package org.apache in my classpath"). Thanks lulian!!!! – xhudik Jan 16 '13 at 08:09
  • 2
    'package.class' is where members defined in [package objects](http://www.scala-lang.org/docu/files/packageobjects/packageobjects.html) are compiled to. This file could be part of another jar on the classpath, not necessarily your own code. I wish the message was simpler, indeed. – Iulian Dragos Jan 27 '13 at 22:05
  • In java terms, its a mismatch with version. Compiler expecting a particular type declaration in package object but found something different. Add suitable version in the classpath to fix this problem. I had the same issue and fixed by adding the matching version of jar. – Nagaraj Vittal Jan 14 '18 at 17:42
2

To me it was JDK not set on PATH neither JAVA_HOME

You can add JAVA_HOME to point to your JDK root folder and add jdk/bin folder (wich inludes javac) directly to the path.

You can refer to the Oracle docs for instruccions on how to add the path http://docs.oracle.com/javase/7/docs/webnotes/install/windows/jdk-installation-windows.html

mancvso
  • 306
  • 4
  • 4
1

In case this helps anyone in the future, I was having this problem with an application I adopted after adding a new class. It turned out that the capitalization in the package name in each class within the package and the actual directory structure were different. Once I lower-cased all of the directory it started working again.

Sherms
  • 1,567
  • 1
  • 15
  • 31
0

First time Scala user. I had some problems in configuring my eclipse and I used to get:

Error:scalac: bad symbolic reference. A signature in package.class refers to type compileTimeOnly
in package scala.annotation which is not available.
It may be completely missing from the current classpath, or the version on
the classpath might be incompatible with the version used when compiling package.class.

Finally found that scala test version 2.11 and compiler version should match. Downloaded scala version 2.11-RC1

Lucas Zamboulis
  • 2,494
  • 5
  • 24
  • 27
idan koch
  • 17
  • 1
  • My pom.xml org.scala-lang scala-library 2.10.6 provided org.apache.spark spark-core_2.10 1.6.2 provided org.apache.spark spark-sql_2.10 1.6.2 provided – BdEngineer Sep 25 '18 at 12:03
  • org.apache.spark spark-hive_2.10 1.6.2 provided com.datastax.spark spark-cassandra-connector_2.11 2.3.0 – BdEngineer Sep 25 '18 at 12:03
  • Where is this scala test verion mentioned ? where should i check compiler version ? – BdEngineer Sep 25 '18 at 12:03