Reputation: 1
I have a scala application with a build.gradle (using gradleVersion 4.4.1). I am using the JUnit Framework. The dependency and test task sections of my gradle.build is below
dependencies {
compile 'org.scala-lang:scala-library:2.11.12'
compile 'org.apache.spark:spark-core_2.11:2.0.2'
compile 'org.apache.spark:spark-sql_2.11:2.0.2'
compile 'org.apache.spark:spark-hive_2.11:2.0.2'
compile 'com.typesafe.play:play-json_2.12:2.6.9'
compile 'com.fasterxml.jackson.module:jackson-module-jsonSchema:2.9.8'
testCompile 'org.scalatest:scalatest_2.11:3.0.0'
testCompile 'junit:junit:4.12'
}
test {
testLogging.showStandardStreams = true
}
When I run gradle test
Task :test FAILED
com.someOrg.gdpschemautils.JsonToSchemaSpec > initializationError FAILED
java.lang.NoClassDefFoundError
Caused by: java.lang.ClassNotFoundException
1 test completed, 1 failed
When I run gradle test --debug
19:20:21.303 [DEBUG] [TestEventLogger] com.someOrg.gdpschemautils.JsonToSchemaSpec > initializationError FAILED
19:20:21.303 [DEBUG] [TestEventLogger] java.lang.NoClassDefFoundError: scala/Product$class
19:20:21.303 [DEBUG] [TestEventLogger] at org.scalatest.time.Units.<init>(Units.scala:33)
19:20:21.304 [DEBUG] [TestEventLogger] at org.scalatest.time.Days$.<init>(Units.scala:293)
19:20:21.304 [DEBUG] [TestEventLogger] at org.scalatest.time.Days$.<clinit>(Units.scala)
19:20:21.304 [DEBUG] [TestEventLogger] at org.scalatest.time.Span$.<init>(Span.scala:584)
19:20:21.304 [DEBUG] [TestEventLogger] at org.scalatest.time.Span$.<clinit>(Span.scala)
19:20:21.304 [DEBUG] [TestEventLogger] at org.scalatest.Suite$.<init>(Suite.scala:1399)
19:20:21.304 [DEBUG] [TestEventLogger] at org.scalatest.Suite$.<clinit>(Suite.scala)
Below is The App Structure.
.
├── README.md
├── build.gradle
├── gradle.properties
├── settings.gradle
├── gradlew
├── gradlew.bat
├── src
└── main
└── scala
└── com
└── someOrg
└── gdpschemautils
├── Config
├── DataSourcePathException
├── JsonToSchema
├── ObjectToJsonSchema
├── SchemaConverter
├── SchemaToJson
└── test
└── resources
├── testJsonSchema.json
└── scala
└── com
└── someOrg
└── gdpschemautils
├── JsonToSchemaSpec
It seems scala classes are not available for the unit tests at run time, I have added testCompile for the scala-library as well in my dependencies and I still get the same error. None of my unit tests will run, rather JsonToSchemaSpec or others.
Upvotes: 0
Views: 5095
Reputation: 2305
Such things usually happen when you accidentally mix different incompatible versions of scala/spark/scaletest. See this for example NoClassDefFoundError: scala/Product$class
Upvotes: 1