On Java, Python, Groovy, Grails, Spring, Node.js, Linux, Arduino, ARM, Embedded Devices & Web

  • Recent Posts

    November 2009
    M T W T F S S
        Jan »
  • Subscribe Options

  • Awards

  • Most Valuable Blogger @ DZone
  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 173 other followers

  • Follow MyThinkPond on
  • Blog Stats

    • 364,698 hits
  • General Options

Scala compile message – Class file or Jar is broken

Posted by Venkatt Guhesan on November 16, 2009

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:

[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] (class net.jcip.annotations.ThreadSafe not found.)

[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] (class net.jcip.annotations.ThreadSafe not found.)

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.


4 Responses to “Scala compile message – Class file or Jar is broken”

  1. Stephan said

    Thanks a bunch – this helped me a lot 🙂

  2. Marius-Andrei Danila said

    Thank you, this was really helpful !

  3. NS du Toit said

    Just encountered a similar problem myself:
    …is broken (class java.lang.NullPointerException/null)

    Turns out it was just using the incorrect type for a method argument. Took me more than half a day to figure out :/

    From googling it also seems that there are other problems that can also give a “class is broken”-type error


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: