java.lang.ClassNotFoundException

发布于 2024-09-05 14:26:06 字数 2929 浏览 9 评论 0原文

我正在开发一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

提笔落墨 2024-09-12 14:26:06

看来您的项目类路径缺少 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).

节枝 2024-09-12 14:26:06

您必须了解两个相似错误消息之间的区别。我建议您阅读 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

寂寞陪衬 2024-09-12 14:26:06

我遇到了类似的问题。我在 gdata api 中没有找到 google-collect-1.0-rc1.jar
但这个线程解决了我的问题:

  • 添加番石榴.xxx.jar 到您的项目中。 Guava 是旧版 Google Collections Library 的完全兼容超集。
  • 您可以在 gdata-samples/java/deps/guava.xxxx.jar 中找到 guava-xxxx.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:

  • Add guava.xxx.jar into your project. Guava is a fully compatible superset of the old Google Collections Library.
  • You can find guava-xxxx.jar in gdata-samples/java/deps/guava.xxxx.jar. Or download it from here.

Google Recommends Guava instead of google-collect-1.0.jar. see here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文