1
votes

When I user sbt assembly, it prints error like this:

[error] (*:assembly) scala.MatchError: org\apache\commons\io\IOCase.class (of class java.lang.String)

and these are my configurations:

1、assembly.sbt:

import AssemblyKeys._
assemblySettings
mergeStrategy in assembly := {
    case PathList("org", "springframework", xs@_*) => MergeStrategy.last
}

2、bulid.sbt

import AssemblyKeys._
lazy val root = (project in file(".")).
  settings(
    name := "DmpRealtimeFlow",
    version := "1.0",
    scalaVersion := "2.11.8",
    libraryDependencies += "com.jd.ads.index" % "ad_index_dmp_common" % "0.0.4-SNAPSHOT",
    libraryDependencies += "org.apache.spark" % "spark-core_2.11" % "2.1.0" % "provided",
    libraryDependencies += "org.apache.spark" % "spark-sql_2.11" % "2.1.0" % "provided",
    libraryDependencies += "org.apache.spark" % "spark-streaming_2.11" % "2.1.0" % "provided",
    libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.8",
    libraryDependencies += "org.springframework" % "spring-beans" % "3.1.0.RELEASE",
    libraryDependencies += "org.springframework" % "spring-context" % "3.1.0.RELEASE",
    libraryDependencies += "org.springframework" % "spring-core" % "3.1.0.RELEASE",
    libraryDependencies += "org.springframework" % "spring-orm" % "3.1.0.RELEASE",
    libraryDependencies += "org.mybatis" % "mybatis" % "3.2.1" % "compile",
    libraryDependencies += "org.mybatis" % "mybatis-spring" % "1.2.2",
    libraryDependencies += "c3p0" % "c3p0" % "0.9.1.2"
  )

3、project tools:

sbt:0.13.5
assembly:0.11.2
java:1.7
scala:2.11.8

any help?

1

1 Answers

0
votes

The problem may be in the missing default case in mergeStrategy in assembly block :

    case x =>
      val oldStrategy = (assemblyMergeStrategy in assembly).value
      oldStrategy(x)

Also, mergeStrategy is deprecated and assemblyMergeStrategy should be used instead.

Basically the

{
    case PathList("org", "springframework", xs@_*) => MergeStrategy.last
}

is a partial function String => MergeStrategy defined for only one type of inputs, i.e. for classes with package prefix "org\springframework". However, it is applied to all class files in the project and the first one that doesn't match the prefix above (org\apache\commons\io\IOCase.class) causes MatchError.