swagger-core
swagger-core copied to clipboard
Scala dependency with swagger-core is incompatible with Scalatest 2.1.x
I'm not sure if this is a resolvable issue with swagger-core. Maybe it's just a matter of upgrading the jackson-module-scala dependency.
Anywho, this is the dependency tree of swagger:
[INFO] | +- com.wordnik:swagger-core_2.10:jar:1.3.5:compile
[INFO] | | +- commons-lang:commons-lang:jar:2.4:compile
[INFO] | | +- com.fasterxml.jackson.module:jackson-module-scala_2.10:jar:2.1.5:compile
[INFO] | | | \- com.thoughtworks.paranamer:paranamer:jar:2.3:compile
[INFO] | | +- com.fasterxml.jackson.module:jackson-module-jsonSchema:jar:2.1.0:compile
[INFO] | | +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.0.0:compile
[INFO] | | | +- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.0.0:compile
[INFO] | | | \- javax.ws.rs:jsr311-api:jar:1.1.1:compile
[INFO] | | +- com.wordnik:swagger-annotations:jar:1.3.5:compile
[INFO] | | +- org.json4s:json4s-ext_2.10:jar:3.2.5:compile
[INFO] | | | \- org.joda:joda-convert:jar:1.2:compile
[INFO] | | +- org.json4s:json4s-native_2.10:jar:3.2.5:compile
[INFO] | | | \- org.json4s:json4s-core_2.10:jar:3.2.5:compile
[INFO] | | | +- org.json4s:json4s-ast_2.10:jar:3.2.5:compile
[INFO] | | | \- org.scala-lang:scalap:jar:2.10.0:compile
Notice that json4s is dependent on scala-lang:2.10.0
This is the warning during compile:
[WARNING] Expected all dependencies to require Scala version: 2.10.3
[WARNING] com.fasterxml.jackson.module:jackson-module-scala_2.10:2.1.5 requires scala version: 2.10.0
[WARNING] Multiple versions of scala libraries detected!
And this is the failure when running the test:
Caused by: java.lang.RuntimeException: There was an error in the forked process
java.lang.NoClassDefFoundError: org/scalatest/Matchers$ResultOfCollectedString
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2531)
at java.lang.Class.getMethod0(Class.java:2774)
at java.lang.Class.getMethod0(Class.java:2783)
at java.lang.Class.getMethod(Class.java:1663)
at org.apache.maven.surefire.util.ReflectionUtils.tryGetMethod(ReflectionUtils.java:57)
at org.apache.maven.surefire.common.junit3.JUnit3TestChecker.isSuiteOnly(JUnit3TestChecker.java:64)
at org.apache.maven.surefire.common.junit3.JUnit3TestChecker.isValidJUnit3Test(JUnit3TestChecker.java:59)
at org.apache.maven.surefire.common.junit3.JUnit3TestChecker.accept(JUnit3TestChecker.java:54)
at org.apache.maven.surefire.common.junit4.JUnit4TestChecker.accept(JUnit4TestChecker.java:52)
at org.apache.maven.surefire.util.DefaultScanResult.applyFilter(DefaultScanResult.java:97)
at org.apache.maven.surefire.junit4.JUnit4Provider.scanClassPath(JUnit4Provider.java:232)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:109)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
As a workaround, I simply added an exclusion on our dependency of Swagger:
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-core_2.10</artifactId>
<version>1.3.5</version>
<exclusions>
<exclusion>
<artifactId>scala-compiler</artifactId>
<groupId>org.scala-lang</groupId>
</exclusion>
</exclusions>
</dependency>
scala dependency is now updated to 2.10.4.