使用适用于 Java 的 AWS 开发工具包运行程序时出现 NoClassDefFoundError
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11018904/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NoClassDefFoundError while running a program using AWS SDK for java
提问by Ben Danon
Im trying to run the DynamoDB sample that comes with the AWS SDK for java. Im doing it using eclipse, and added the aws-java-sdk-1.3.2.jar
file to the build path of the project. Compilation of course goes fine, but im getting a runtime exception named NoClassDefFoundError
.
I know it means that the class was there at compilation but couldn't be found at runtime.
I tried adding the jar file to env variables - didn't help.
I also checked and there is no problem using other external jar files on other projects.
Same problem on both windows and linux.
我正在尝试运行 AWS SDK for java 附带的 DynamoDB 示例。我使用 eclipse 进行操作,并将aws-java-sdk-1.3.2.jar
文件添加到项目的构建路径中。编译当然没问题,但我收到了一个名为NoClassDefFoundError
. 我知道这意味着该类在编译时就在那里,但在运行时找不到。我尝试将 jar 文件添加到 env 变量 - 没有帮助。我还检查过,在其他项目上使用其他外部 jar 文件没有问题。windows 和 linux 都存在同样的问题。
help anyone?
帮助任何人?
Thanks, ben.
谢谢,本。
Stack Trace:
堆栈跟踪:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at com.amazonaws.services.dynamodb.AmazonDynamoDBClient.<clinit>(AmazonDynamoDBClient.java:62)
at AmazonDynamoDBSample.init(AmazonDynamoDBSample.java:62)
at AmazonDynamoDBSample.main(AmazonDynamoDBSample.java:67)
回答by Pedro Aurélio
Inside the aws-java-sdk-1.3.2folder you will find another folder named "third-party". All the third-party files used by Amazon SDK are inside that folder, including Apache Common Logging. You have to add the required files to your classpath along with AWS SDK jar files.
在aws-java-sdk-1.3.2文件夹中,您会找到另一个名为“第三方”的文件夹。Amazon SDK 使用的所有第三方文件都在该文件夹中,包括 Apache Common Logging。您必须将所需的文件与 AWS SDK jar 文件一起添加到您的类路径中。
回答by Edwin Buck
It looks like your AWS JAR needs a few extra JARs to implement used, but non-AWS items (like in your case logging).
看起来您的 AWS JAR 需要一些额外的 JAR 来实现使用过的非 AWS 项目(例如您的案例日志记录)。
If you downloaded a distributable that contains a "lib" directory, odds are you only configured Eclipse to use the AWS JAR instead of all the required JARs, including AWS and probably all the JARs in the "lib" directory.
如果您下载了一个包含“lib”目录的可分发文件,很可能您只将 Eclipse 配置为使用 AWS JAR 而不是所有必需的 JAR,包括 AWS 和“lib”目录中可能的所有 JAR。