views:

261

answers:

2

Hey everyone,

I have a java project that I'm working on which was working until a few days ago. I'm not sure what I did to my Eclipse set-up to hose it but now I'm getting a java.lang.ClassNotFoundException when I try to run some code that accesses the google finance api. I've built a small test application that uses the google finance api on its own and that seems to work. So, I think this is a project specific problem. Any help would be greatly appreciated. Here's the stack trace:

ptolemy.kernel.util.IllegalActionException:   in .RandomSearch.manager
Because:
com/google/common/collect/Maps
 at ptolemy.actor.Manager.execute(Manager.java:472)
 at ptolemy.actor.Manager.run(Manager.java:1119)
 at ptolemy.actor.Manager$3.run(Manager.java:1160)
Caused by: java.lang.NoClassDefFoundError: com/google/common/collect/Maps
 at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:118)
 at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:100)
 at com.google.gdata.client.Service.<clinit>(Service.java:546)
 at AtomicBroadcast.GoogleFinance.GooglePortfolioReader.fire(GooglePortfolioReader.java:108)
 at ptolemy.domains.de.kernel.DEDirector.fire(DEDirector.java:568)
 at ptolemy.actor.CompositeActor.fire(CompositeActor.java:458)
 at ptolemy.actor.Manager.iterate(Manager.java:714)
 at ptolemy.actor.Manager.execute(Manager.java:349)
 ... 2 more
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Maps
 at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
 at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
 ... 10 more
Caused by: java.lang.NoClassDefFoundError: com/google/common/collect/Maps
 at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:118)
 at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:100)
 at com.google.gdata.client.Service.<clinit>(Service.java:546)
 at AtomicBroadcast.GoogleFinance.GooglePortfolioReader.fire(GooglePortfolioReader.java:108)
 at ptolemy.domains.de.kernel.DEDirector.fire(DEDirector.java:568)
 at ptolemy.actor.CompositeActor.fire(CompositeActor.java:458)
 at ptolemy.actor.Manager.iterate(Manager.java:714)
 at ptolemy.actor.Manager.execute(Manager.java:349)
 at ptolemy.actor.Manager.run(Manager.java:1119)
 at ptolemy.actor.Manager$3.run(Manager.java:1160)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Maps
 at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
 at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
 ... 10 more
+2  A: 

It seems that your project classpath is lacking google-collect-1.0-rc1.jar

You obviously have it on your hard drive, just edit the project classpath and add it there (or make sure it gets added by Maven/such if you use them).

Lauri Lehtinen
This fixed the problem. Thanks so much. I am almost certain that I never explicitly added google-collect-1.0-rc1.jar to the classpath before but this was absolutely the issue. Thanks again.
Eclipse works in mysterious ways! Happy to help
Lauri Lehtinen
Wait -- why use an early release candidate of a library that was later released? (Not to mention that even that release is now deprecated in favor of Guava. Just download Guava and use it instead; it's a 100% compatible superset, but has fixed bugs and such.)
Kevin Bourrillion
@Kevin - very good questions. I suggested the rc because that's what's included in the dep directory of the package I downloaded from Google code to try some of their APIs.
Lauri Lehtinen
A: 

You will have to be aware of the difference between two similar error messages. I suggest you read the fantastic article "Difference between ClassNotFoundException and NoClassDefFoundError" from Sanjiv Jivan. http://www.jroller.com/sjivan/entry/difference_between_classnotfoundexception_and_noclassdeffounderror

Wizard of Kneup