user1052610
user1052610

Reputation: 4719

Scala package throws java.lang.UnsupportedClassVersionError

Our java application has dependencies on Spark, which is written in Scala. Build tool is Maven, and am running from within Eclipse. The JDK_HOME used to compile the application on the command line using Maven, and the JRE used to run within Eclipse, are both 1.7.0_15.

The Maven POM contains the following:

<plugin>
   <groupId>org.scala-tools</groupId>
   <artifactId>maven-scala-plugin</artifactId>
   ...
   <configuration>
      <scalaVersion>1.10.5</scalaVersion>
         <args>
            <arg>-target:jvm-1.7</arg>
         </args>
   </configuration>
</plugin>

I understand that Spark is built using Scala 2.10

The maven dependencies include the following:

<dependency>
   <groupId>org.apache.spark</groupId>
   <artifactId>spark-core_2.11</artifactId>
   <version>1.3.1</version>
</dependency>

<dependency>
   <groupId>org.elasticsearch</groupId>
   <artifactId>elasticsearch-hadoop</artifactId>
   <version>2.1.0.Beta4</version>
</dependency>

<dependency>
   <groupId>org.elasticsearch</groupId>
   <artifactId>elasticsearch-spark_2.10</artifactId>
   <version>2.1.0.Beta4</version>
</dependency>

<dependency>
   <groupId>org.scala-lang</groupId>
   <artifactId>scala-xml</artifactId>
   <version>2.11.0-M4</version>
</dependency>

<dependency>
   <groupId>org.scala-lang.modules</groupId>
   <artifactId>scala-parser-combinators_2.12.0-M2</artifactId>
   <version>1.0.4</version>
   </dependency>

<dependency>
   <groupId>org.apache.spark</groupId>
   <artifactId>spark-sql_2.10</artifactId>
   <version>1.3.0</version>
</dependency

>

At runtime, the folowing exception is thrown:

Exception in thread "main" java.lang.UnsupportedClassVersionError: scala/util/parsing/combinator/PackratParsers : Unsupported major.minor version 52.0

I cannot find a 2.10.* version of the scala-parser-combinators jar.

Can anyone assist with the solution?

Thanks!

Upvotes: 0

Views: 200

Answers (1)

mikołak
mikołak

Reputation: 9705

The scala-parser-combinators_2.12.0-M2 module is part of the Scala 2.12 distribution.

2.12 is targeted for Java 8 - bytecode major version 52, hence the error.

Your best bet is to either use an older Spark distribution or switch to Java 8 (Java 7 is at End-Of-Life since April 2015).

EDIT (addressing question edit): you cannot find an older version of the scala-parser-combinators library, because it was isolated to a stand-alone module at some point after 2.10. You can attempt to simply exclude this dependency in your POM, but there's no guarantee your chosen Spark version will be compatible with this older library version.

Upvotes: 2

Related Questions