By Alvin Alexander. Last updated: September 19, 2016
I just ran into the following Scala jar (class) is broken error:
$ sbt run [info] Loading global plugins from /Users/Al/.sbt/plugins [info] Set current project to XStream (in build file:/Users/Al/Projects/Scala/Tests/CookbookReviews/XStream/) [info] Compiling 2 Scala sources to /Users/Al/Projects/Scala/Tests/CookbookReviews/XStream/target/scala-2.10/classes... [warn] Class org.codehaus.jettison.mapped.Configuration not found - continuing with a stub. [error] error while loading JettisonMappedXmlDriver, class file '/Users/Al/Projects/Scala/Tests/CookbookReviews/XStream/lib/xstream-1.4.4.jar(com/thoughtworks/xstream/io/json/JettisonMappedXmlDriver.class)' is broken [error] (class java.lang.NullPointerException/) [warn] one warning found [error] one error found [error] (compile:compile) Compilation failed [error] Total time: 5 s, completed Mar 24, 2013 2:07:51 PM
In short, this happened because I only had the main XStream jar file, and didn't have all the other jar files it depended on. Once I added all of XStream's dependencies, this "jar class is broken" error was resolved.
FWIW, I found the hint to solving this problem on the previous line of SBT output, where it said the Configuration file was not found. That, combined with the NullPointerException
error, provided the necessary clues. Once I looked at the package it was supposed to be in, I realized that the XStream jar had dependencies, and once I resolved those dependencies, the error went away.