java.lang.ClassNotFoundException
我正在开发一个 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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看来您的项目类路径缺少
google-collect-1.0-rc1.jar
您显然在硬盘上有它,只需编辑项目类路径并将其添加到那里(或者确保它被添加Maven/此类(如果您使用它们)。
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).
您必须了解两个相似错误消息之间的区别。我建议您阅读 Sanjiv Jivan 撰写的精彩文章“ClassNotFoundException 和 NoClassDefFoundError 之间的差异”。
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
我遇到了类似的问题。我在 gdata api 中没有找到
google-collect-1.0-rc1.jar
。但这个线程解决了我的问题:
Google 推荐使用 Guava,而不是 google-collect-1.0.jar。 参见此处
I run across the similiar problem. I didn't found
google-collect-1.0-rc1.jar
in gdata api.But this thread solved my problem:
Google Recommends Guava instead of google-collect-1.0.jar. see here