导入具有内部类的类时出现 NoClassDefFoundError
我无法从 jar 中导入特定的类 (FinanceService
)。所有其他都工作正常,包括内部类 FinanceService$Versions
。我收到 NoClassDefFound
异常,但我不知道如何继续。
这个异常发生了,解释一下我在这里找到的答案,当源代码成功编译,但在运行时,找不到所需的类文件,但我可以在.jar中清楚地看到它,其第一个元素是:
META-INF/ META-INF/MANIFEST.MF com/ com/google/ com/google/gdata/ com/google/gdata/client/ com/google/gdata/client/finance/ com/google/gdata/data/ com/google/gdata/data/finance/ com/google/gdata/client/finance/FinanceService$Versions.class com/google/gdata/client/finance/FinanceService.class com/google/gdata/client/finance/FinanceUtilities.class com/google/gdata/client/finance/PortfolioQuery.class
为了确定,我重建了罐子,但仍然遇到相同的错误。由于它是唯一一个既具有内部类又无法加载的类,我认为必须有一种特殊的方式来加载它,但是 这段代码证明了相反的情况。知道该怎么做吗?
谢谢!
I'm not being able to import a particular class (FinanceService
) from a jar. All the others work fine, including the inner-class FinanceService$Versions
. I'm getting a NoClassDefFound
exception, and I'm not sure how to proceed.
This exception occurs, paraphrasing an answer I've found here, when the source was successfully compiled, but at runtime, the required class files were not found, but I can clearly see it inside the .jar, whose first elements are:
META-INF/ META-INF/MANIFEST.MF com/ com/google/ com/google/gdata/ com/google/gdata/client/ com/google/gdata/client/finance/ com/google/gdata/data/ com/google/gdata/data/finance/ com/google/gdata/client/finance/FinanceService$Versions.class com/google/gdata/client/finance/FinanceService.class com/google/gdata/client/finance/FinanceUtilities.class com/google/gdata/client/finance/PortfolioQuery.class
Just to be sure, I rebuilt the jars, and still got the same error. Since it is the only class that both has an inner class and is failing to load, I considered the hypothesis that there must be a special way of loading it, but this code proves the contrary. Any idea what to do?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该 jar 显然有很多依赖项,请确保在启动 Clojure 时将所有这些依赖项都放在 CLASSPATH 上。还要确保您没有混合版本。我跳过了您上面的
gdata-finance-2.0.jar
的下载链接,而是下载了 http://gdata-java-client.googlecode.com/files/gdata-src.java-1.26.0.java.zip 来自您链接的项目页面,该页面在gdata/java/lib
中附带了大量 jar 文件,其中之一是财务 jar。所以我解压了所有内容并执行了以下操作:这显然有效。但现在
FinanceService$Versions
不存在。它也不存在于FinanceService.java
中。我猜测,它可能是与您正在使用的库版本不同的库。如果您收到
NoClassDefFound
消息,请务必注意未找到哪个类。FinanceService
可能会丢失,但它也可能会抱怨其依赖项之一丢失。That jar apparently has lots of dependencies, make sure you have all of them on CLASSPATH when you start Clojure. Also make sure you aren't mixing versions. I skipped the download link for
gdata-finance-2.0.jar
that you have up there, and instead downloaded http://gdata-java-client.googlecode.com/files/gdata-src.java-1.26.0.java.zip from the project page you linked, which came with a ton of jar files ingdata/java/lib
, one of which was the finance jar. So I unzipped everything and did this:This apparently worked. But now
FinanceService$Versions
doesn't exist. It doesn't exist inFinanceService.java
either. It's probably a different version of the library than what you are using, would be my guess.If you're getting
NoClassDefFound
, be sure you're paying attention to what class it isn't finding.FinanceService
might be missing, but it might also be complaining that one of its dependencies is missing.