新的DefaultHttpClient()出现奇怪的Java错误

时间:2013-07-07 03:30:17

标签: java apache http

出于某种原因,从我的Bukkit插件中获取以下错误。错误开始的UpdatePlayer.java行58是HttpClient httpclient = new DefaultHttpClient();

2013-07-06 21:22:28
[SEVERE] at com.adventurize.players.UpdatePlayer.run(UpdatePlayer.java:58)

2013-07-06 21:22:28
[SEVERE] at org.apache.http.impl.client.DefaultHttpClient.<init>(DefaultHttpClient.java:146)

2013-07-06 21:22:28
[SEVERE] at org.apache.http.impl.client.AbstractHttpClient.<init>(AbstractHttpClient.java:187)

2013-07-06 21:22:28
[SEVERE] at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)

2013-07-06 21:22:28
[SEVERE] at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:316)

2013-07-06 21:22:28
[SEVERE] at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:517)

2013-07-06 21:22:28
[SEVERE] at java.security.AccessController.doPrivileged(Native Method)

2013-07-06 21:22:28
[SEVERE] at org.apache.commons.logging.LogFactory$2.run(LogFactory.java:531)

2013-07-06 21:22:28
[SEVERE] at java.lang.Class.newInstance(Class.java:327)

2013-07-06 21:22:28
[SEVERE] at java.lang.Class.newInstance0(Class.java:374)

2013-07-06 21:22:28
[SEVERE] at java.lang.reflect.Constructor.newInstance(Constructor.java:525)

2013-07-06 21:22:28
[SEVERE] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

2013-07-06 21:22:28
[SEVERE] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

2013-07-06 21:22:28
[SEVERE] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

2013-07-06 21:22:28
[SEVERE] at org.apache.commons.logging.impl.LogFactoryImpl.<init>(LogFactoryImpl.java:95)

2013-07-06 21:22:28
[SEVERE] at org.apache.commons.logging.impl.LogFactoryImpl.initDiagnostics(LogFactoryImpl.java:476)

2013-07-06 21:22:28
[SEVERE] at org.apache.commons.logging.impl.LogFactoryImpl.getClassLoader(LogFactoryImpl.java:447)

2013-07-06 21:22:28
[SEVERE] java.lang.NoSuchMethodError: org.apache.commons.logging.LogFactory.getClassLoader(Ljava/lang/Class;)Ljava/lang/ClassLoader;

2013-07-06 21:22:28
[SEVERE] Exception in thread "Thread-8"

这在我尝试插件的第一台服务器上工作正常,但随后我们切换服务器,我收到了这个错误。任何见解都会非常感激。

1 个答案:

答案 0 :(得分:1)

的例外是,加载类加载器的LogFactory版本没有带签名的方法:

    Classloader LogFactory.getClassLoader(Class)

发生的事情是您的应用程序(或某些第三方JAR)是针对org.apache.commons.logging.LogFactory API的一个版本编译的,但您的运行时正在加载不同的版本。

根据项目的在线javadocs,getClassLoader(Class)方法存在于公共日志记录的1.1.x版本中,但不存在于1.0.4版本中。 (这是一个半内部方法......它声明protected ...所以依赖性更可能来自实现或扩展log4j而不是来自客户端代码的某些JAR。)