6

I am hitting the above error on scala 2.11.7:

def main(args: Array[String]): Unit = {
  val x = typeOf[ org.apache.hadoop.io.Writable ]
  println( x )
}

Additional info of my compilation process:

I've narrowed to the bare minimum necessary to reproduce:

I have a project with a build.gradle like so:

buildscript {
  repositories {
      mavenCentral()
      maven {
        name 'Shadow'
        url 'http://dl.bintray.com/content/johnrengelman/gradle-    plugins'
      }
  }
  dependencies {
    classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.1'
  }
}

apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'scala'

repositories {
    mavenCentral()
}

dependencies 
{
  compile group: 'org.scala-lang', name: 'scala-library', version: '2.11.7'
  compile group: 'org.scala-lang', name: 'scala-reflect', version: '2.11.7'
  compile( "org.apache.hadoop:hadoop-common:2.4.0" )
}

This is my main:

import scala.reflect.runtime.universe._

object Test 
{
  def main(args: Array[String]): Unit = {
     val x = typeOf[ org.apache.hadoop.io.Writable ]
     println( x )
  }  
}

Building with:

gradle clean shadow

produces a jar with all dependencies.

java -cp ./build/libs/uber.jar Test

Results in the above exception

Harel Gliksman
  • 734
  • 1
  • 7
  • 19

1 Answers1

0

Scala seems to fail upon reflecting on the Hadoop annotations, e.g. InterfaceAnnotations. The solution is to exclude the hadoop-annotations dependency:

configurations {
    all*.exclude group: 'org.apache.hadoop', module: 'hadoop-annotations'
}
Eron Wright
  • 1,022
  • 12
  • 10