我有一个我正在研究的java项目,直到几天前才开始工作。我不确定我对我的Eclipse设置做了什么来软管它但现在当我尝试运行一些访问google finance api的代码时,我得到了一个java.lang.ClassNotFoundException。我已经构建了一个小型测试应用程序,它自己使用google finance api,这似乎有效。所以,我认为这是一个项目特定的问题。任何帮助将不胜感激。这是堆栈跟踪:
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
答案 0 :(得分:4)
您的项目类路径似乎缺少google-collect-1.0-rc1.jar
你显然在你的硬盘上有它,只需编辑项目类路径并将其添加到那里(或确保它由Maven /如果你使用它们添加)。
答案 1 :(得分:1)
您必须了解两个类似错误消息之间的区别。我建议你阅读Sanjiv Jivan的精彩文章“ClassNotFoundException和NoClassDefFoundError之间的区别”。 http://www.jroller.com/sjivan/entry/difference_between_classnotfoundexception_and_noclassdeffounderror
答案 2 :(得分:1)