Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class broken error with Joda Time using Scala

I'm adding the Joda Time repository to SBT with

libraryDependencies ++= Seq(
  "joda-time"         % "joda-time"           % "2.1"
)

Then I merrily use it like this:

 val ymd = org.joda.time.format.DateTimeFormat.forPattern("yyyyMMdd")
  ymd.parseDateTime("20121212")

But, when I compile the project in SBT, I get a nasty:

[warn] Class org.joda.convert.FromString not found - continuing with a stub.
[warn] Caught: java.lang.NullPointerException while parsing annotations in /home/jack/.ivy2/cache/joda-time/joda-time/jars/joda-time-2.1.jar(org/joda/time/DateTime.class)
[error] error while loading DateTime, class file '/home/jack/.ivy2/cache/joda-time/joda-time/jars/joda-time-2.1.jar(org/joda/time/DateTime.class)' is broken
[error] (class java.lang.RuntimeException/bad constant pool tag 10 at byte 42)

I tried the 2.0 version of joda-time, but get the same error.

like image 501
Jack Avatar asked Dec 13 '12 09:12

Jack


2 Answers

Add this dependency:

"org.joda" % "joda-convert" % "1.8.1"

It's an optional dependency of joda-time. I had to add it in my own project for the scala compiler to accept working with the joda-time jar.

Your issue seems to be the same.

Version is as at time of editing, latest versions can be found here

like image 135
David Pierre Avatar answered Nov 16 '22 05:11

David Pierre


I was running into a similar issue:

[warn] Class net.jcip.annotations.NotThreadSafe not found - continuing with a stub.
[warn] Caught: java.lang.NullPointerException while parsing annotations in ~/.ivy2-p2/cache/org.opensaml/xmltooling/jars/xmltooling-1.3.4.jar(org/opensaml/xml/util/IDIndex.class)
[error] error while loading AttributeMap, class file '~/.ivy2-p2/cache/org.opensaml/xmltooling/jars/xmltooling-1.3.4.jar(org/opensaml/xml/util/AttributeMap.class)' is broken
[error] (class java.lang.RuntimeException/bad constant pool index: 0 at pos: 12058)

Explicitly adding a dependency jcip-annotations-1.0.jar resolved the issue.

like image 24
mn2013 Avatar answered Nov 16 '22 03:11

mn2013