I'm trying to run scala applications under tomcat, and whenever I use standard java stuff, I seem okay. However, when I do things like string concatenation or sequence generation, I get weird errors for NoClassDefFound...

My first thoughts are that I'm not putting the required scala-library jar in the correct directories, or I need to do some additional configuration to make my servlet aware of the external dependency. I've tried putting scala-library.jar in both the tomcat6 "lib" directory and under ROOT/WEB-INF/lib, but neither seem to allow my servlets to use classes in the jar. What's going on?


Check your CLASSPATH environment variable contains the path to your scala-library.jar file, before you start tomcat.

  • Really? I thought just putting it in the lib directory was enough. If this works, you're the champion of the trilogy overflow sites. – Stefan Kendall Sep 28 '09 at 20:18

If you put the scala-library.jar into the JRE/lib/ext directory, that should work. This of course, is the JRE that is running Tomcat. This places scala in the "default classloader" instead of within Tomcats classloader... and in theory, should solve your issue. In effect, this is the same as Tom O'Connors answer except I am telling you why you got the class not found error: because of the custom classloader.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.