joda time 2.0

1,856 views
Skip to first unread message

Jan Kriesten

unread,
Aug 5, 2011, 3:09:30 AM8/5/11
to scala...@googlegroups.com

Hi,

I just tried to use joda time 2.0 (from the maven repo) with scala
2.9.0-1. It seems that the compiler can't analyze the lib:

[INFO] ...: info: compiling
[INFO] Compiling 3 source files to .../target/classes at 1312527976035
[ERROR] error: error while loading DateTime, Missing dependency 'class
org.joda.convert.FromString', required by
/Users/kriesten/.m2/repository/joda-time/joda-time/2.0/joda-time-2.0.jar(org/joda/time/DateTime.class)
[ERROR] error: error while loading AbstractInstant, Missing dependency
'class org.joda.convert.ToString', required by
/Users/kriesten/.m2/repository/joda-time/joda-time/2.0/joda-time-2.0.jar(org/joda/time/base/AbstractInstant.class)
[ERROR] .../Converter.scala:20: error: org.joda.time.DateTime does not
have a constructor
[INFO] new DateTime( date )
[INFO] ^
[ERROR] three errors found

This works fine with joda time 1.6.2. I double checked the 2.0 jar is
ok, also, the files can be decompiled fine using jad.

Any hint what might go wrong here?

Best regards, --- Jan.

Jason Zaugg

unread,
Aug 5, 2011, 3:18:21 AM8/5/11
to Jan Kriesten, scala...@googlegroups.com
You need to explicitly include 'joda-convert', which is marked as a
optional dependency in the joda-time POM [1]

<dependency>
<groupId>org.joda</groupId>
<artifactId>joda-convert</artifactId>
<version>1.1</version>
</dependency>

The Scala compiler requires that all classes referenced in signatures
of classes that you use are also available on the compile time
classpath.

-jason

[1] http://search.maven.org/remotecontent?filepath=joda-time/joda-time/2.0/joda-time-2.0.pom

JodaStephen

unread,
Aug 6, 2011, 7:18:40 AM8/6/11
to scala-user
This library dependency should be optional. Annotations in Java are
optional - if they aren't found, the class still loads and runs.
Clearly Scala isn't respecting that.

I only included this in Joda-Time because of how Java annotations are
optional. No one should be forced to pick this up this as a
dependency. Can Scala be changed/fixed?

Stephen


On Aug 5, 8:18 am, Jason Zaugg <jza...@gmail.com> wrote:
> You need to explicitly include 'joda-convert', which is marked as a
> optional dependency in the joda-time POM [1]
>
> <dependency>
>   <groupId>org.joda</groupId>
>   <artifactId>joda-convert</artifactId>
>   <version>1.1</version>
> </dependency>
>
> The Scala compiler requires that all classes referenced in signatures
> of classes that you use are also available on the compile time
> classpath.
>
> -jason
>
> [1]http://search.maven.org/remotecontent?filepath=joda-time/joda-time/2....

Jason Zaugg

unread,
Aug 6, 2011, 8:08:21 AM8/6/11
to JodaStephen, scala-user
On Sat, Aug 6, 2011 at 1:18 PM, JodaStephen <jodas...@gmail.com> wrote:
> This library dependency should be optional. Annotations in Java are
> optional - if they aren't found, the class still loads and runs.
> Clearly Scala isn't respecting that.
>
> I only included this in Joda-Time because of how Java annotations are
> optional. No one should be forced to pick this up this as a
> dependency. Can Scala be changed/fixed?

You only need it at compile time, use the "provided" scope in Maven for that.

-jason

Tim P

unread,
Aug 14, 2011, 4:01:38 AM8/14/11
to scala-user
Has anyone any suggests as to what I can do about this as a user?
I'm compiling within intellij using the scala module.

The problem is that I get this;
error while loading Period, Missing dependency 'class
org.joda.convert.FromString', required by C:\programmingExperiments
\joda-time-2.0\joda-time-2.0.jar(org/joda/time/Period.class)

repeated for each of the types at the top of the Make error list. It
doesn't tell me which or what I need to modify in order to make it go
away.
Does this mean I simply can't make it compile, or do I have to go
around importing org.joda.time.convert._into every scala file that
requires it?

Has anybody any interest in sorting this out? Or are you just going to
blame each other? Right now it looks like I've got to go back to a
previous version of jodatime, which is a shame because I do use joda
everywhere.

Tim

On Aug 6, 12:18 pm, JodaStephen <jodastep...@gmail.com> wrote:
> This library dependency should be optional. Annotations in Java are
> optional - if they aren't found, the class still loads and runs.
> Clearly Scala isn't respecting that.
>
> I only included this inJoda-Time because of how Java annotations are
> optional. No one should be forced to pick this up this as a
> dependency. Can Scala be changed/fixed?
>
> Stephen
>
> On Aug 5, 8:18 am, Jason Zaugg <jza...@gmail.com> wrote:
>
>
>
>
>
>
>
> > You need to explicitly include 'joda-convert', which is marked as a
> > optional dependency in thejoda-time POM [1]
>
> > <dependency>
> >   <groupId>org.joda</groupId>
> >   <artifactId>joda-convert</artifactId>
> >   <version>1.1</version>
> > </dependency>
>
> > The Scala compiler requires that all classes referenced in signatures
> > of classes that you use are also available on the compile time
> > classpath.
>
> > -jason
>
> > [1]http://search.maven.org/remotecontent?filepath=joda-time/joda-time/2....
>
> > On Fri, Aug 5, 2011 at 9:09 AM, Jan Kriesten <kries...@mail.footprint.de> wrote:
>
> > > Hi,
>
> > > I just tried to usejodatime 2.0 (from the maven repo) with scala
> > > 2.9.0-1. It seems that the compiler can't analyze the lib:
>
> > > [INFO] ...: info: compiling
> > > [INFO] Compiling 3 source files to .../target/classes at 1312527976035
> > > [ERROR] error: error while loading DateTime, Missing dependency 'class
> > > org.joda.convert.FromString', required by
> > > /Users/kriesten/.m2/repository/joda-time/joda-time/2.0/joda-time-2.0.jar(or g/joda/time/DateTime.class)
> > > [ERROR] error: error while loading AbstractInstant, Missing dependency
> > > 'class org.joda.convert.ToString', required by
> > > /Users/kriesten/.m2/repository/joda-time/joda-time/2.0/joda-time-2.0.jar(or g/joda/time/base/AbstractInstant.class)
> > > [ERROR] .../Converter.scala:20: error: org.joda.time.DateTime does not
> > > have a constructor
> > > [INFO]     new DateTime( date )
> > > [INFO]     ^
> > > [ERROR] three errors found
>
> > > This works fine withjodatime 1.6.2. I double checked the 2.0 jar is

Jason Zaugg

unread,
Aug 14, 2011, 4:22:19 AM8/14/11
to Tim P, scala-user
Add this JAR to your classpath:

<dependency>
<groupId>org.joda</groupId>
<artifactId>joda-convert</artifactId>
<version>1.1</version>
</dependency>

-jason

Meeraj Kunnumpurath

unread,
Sep 18, 2013, 9:43:13 AM9/18/13
to scala...@googlegroups.com, Tim P
This only works if the scope is not test. I am only using Scala for my test classes, but I am forced to add this as a provided dependency.
Reply all
Reply to author
Forward
0 new messages