To compile XML syntax, the scala.xml package must be on the classpath

I was creating a servlet using Scala and got the following error message “To compile XML syntax, the scala.xml package must be on the classpath”. It turns out that Scala-XML has been factored out into a separate library as of Scala 2.11, so it is not included in Scala projects by default. So the dependency needs to be include in the project build.sbt using the following statement:

libraryDependencies += "org.scala-lang.modules" %% "scala-xml" % "1.0.2"

Note as always you should check that there isn’t a newer version available of the library. How? Google is your friend 🙂

maven org.scala-lang.modules scala-xml

Happy coding!

Leave a comment