Scala compile message - Class file or Jar is broken | MyThinkPond

Sometimes when compiling my Scala code, the compiler output may need a little bit of help in sorting out what’s the real issue.

For example, when I compiled today I received the following error:

[sourcecode language=“jscript”]

[scalac] error: error while loading DefaultHttpClient, class file ‘C:\A_OpenSource\WicketNotesApp\lib\httpclient-4.0.jar(org/apache/http/impl/client/DefaultHttpClient.class)’ is broken scalac

[scalac] error: error while loading AbstractHttpClient, class file ‘C:\A_OpenSource\WicketNotesApp\lib\httpclient-4.0.jar(org/apache/http/impl/client/AbstractHttpClient.class)’ is broken scalac

[/sourcecode]

And my instinct tells me to focus on the jar file or the class file and in this case, “DefaultHttpClient.class” or “AbstractHttpClient.class” or “httpclient-4.0.jar”. There’s noting wrong with your jar file or the Java class. The actual problem is in the next line, namely “class net.jcip.annotations.ThreadSafe not found.” It’s a class-not-found error.

So if you encounter a “broken” error when compiling Scala - the following line after the broken message can help you find the real error. It can save you a whole lot of head-aches and chasing the wrong tail.

If you find this article useful, consider signing up for my RSS feed or Email Newsletter. See links on the right side.
Venkatt Guhesan avatar
About Venkatt Guhesan
Enterprise Software Architect currently working at DataDirect Networks developing a highly scalable monitoring solution called DDN Insight. My passions include all things Open Source including Linux (CentOS, Red Hat, Gentoo, Open Stack, Docker & Ubuntu), embedded ARM processors and microcontrollers (Arduino, UDOO, Cubieboard, BeagleBoard, OnionIO, TI's Zigbee). Coming from an Electrical and Computer Engineering background, working in developing and designing enterprise - distributed, highly scalable software requires a unique set of software skills with a good understanding of the hardware. This makes his work challenging and interesting. In his free time, he spends his time with his family and two children. He also enjoys researching on topics including - world ancient history and yoga. Visit the 'About' section for more details.
comments powered by Disqus