java.lang.ClassNotFoundException

user341493 picture user341493 · Jun 10, 2010 · Viewed 9.9k times · Source

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

Answer

Lauri Lehtinen picture Lauri Lehtinen · Jun 10, 2010

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).