简体   繁体   English

jar中的AWS开发工具包NoClassDefFoundError用作smartfox的扩展

[英]AWS SDK NoClassDefFoundError in jar used as an extension of smartfox

I'm exporting a project to a jar that is used as a server extension in SmartFox, my project uses Amazon AWS SDK to upload some files to the cloud. 我将一个项目导出到一个在SmartFox中用作服务器扩展的jar中,我的项目使用Amazon AWS开发工具包将一些文件上传到云中。 The problem is that when I run the SmartFox it throws this exception: 问题是,当我运行SmartFox时,它将引发此异常:

Exception in thread "Thread-22" java.lang.NoClassDefFoundError: com/amazonaws/auth/AWSCredentials at...
Caused by: java.lang.ClassNotFoundException: com.amazonaws.auth.AWSCredentials
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more

The AWSCredentials class is in the classpath, when I downloaded the SDK files I notice that there was a "third-party" folder with jars that the AWS may need, I wasn't sure if I had to add them to the classpath, so I did it, but nothing changed.. also my project is a regular java project, not a web project, could that be the problem? AWSCredentials类位于类路径中,当我下载SDK文件时,我注意到存在一个可能包含AWS可能需要的jar的“第三方”文件夹,我不确定是否必须将它们添加到类路径中,因此我做到了,但是什么都没有改变..我的项目还是一个常规的Java项目,而不是Web项目,这可能是问题吗? If that's the case I'm screwed cause I'm not allowed to change the project type.. Thanks for any help in advance... 如果那样的话,我就搞砸了,因为不允许我更改项目类型。

The answer was pretty easy, SmartFox has a /SmartFoxServer_2X/SFS2X/extensions/__ lib __ directory where you are supposed to put all the jars that your extension jar may need. 答案很简单,SmartFox有一个/SmartFoxServer_2X/SFS2X/extensions/__ lib __目录,您应该在其中放置扩展jar可能需要的所有jar。

I pasted all the "third-party" jars and the SDK jar itself inside this directory and it almost worked. 我将所有“第三方”罐子和SDK罐子本身粘贴到此目录中,并且几乎可以正常工作。 The problem that I faced after that was an incompatibility between two jars from the same library (http-client from apache), one residing at __ lib __ and the other residing at /SmartFoxServer_2X/SFS2X/lib that contains all the jars that SmartFox uses. 之后,我面临的问题是同一个库(apache中的http-client)的两个jar之间不兼容,其中一个驻留在__ lib __ ,另一个驻留在/SmartFoxServer_2X/SFS2X/lib ,其中包含SmartFox使用的所有jar 。

I think the problem was that the SmartFox classloader was loading the http-client .class files from the jar located at /SmartFoxServer_2X/SFS2X/lib whose version was a bit older than the one I pasted from the Amazon third party libraries and didn't have a couple of methods that AWS needed. 我认为问题在于SmartFox类加载器正在从/SmartFoxServer_2X/SFS2X/lib的jar加载http-client .class文件,其版本比我从Amazon第三方库粘贴的版本/SmartFoxServer_2X/SFS2X/lib旧,但没有有AWS需要的几种方法。 Anyway, I updated SmartFox to the lastest version and that did the trick. 无论如何,我将SmartFox更新到最新版本,并且达到了目的。 Of course I also could have pasted the jar from the __ lib __ folder to lib to have the same version. 当然,我也可以将__ lib __文件夹中的jar粘贴到lib以具有相同的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM