神秘的NoSuchMethodError&它不能是classpath ...可以吗? [英] Mysterious NoSuchMethodError & it can't be the classpath...can it?

查看:171
本文介绍了神秘的NoSuchMethodError&它不能是classpath ...可以吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在和这个bug玩了3个小时。
我检查了构建路径和类路径,它们是相同的,这是一个相当大的webapp,在Tomcat& Geronimo,它有一个构建文件为每个组件&然后一个主要的一次将它们捆绑在一起,但是我已经完成了ant构建文件和将它们与依赖第三方库的工作组件中的其他人进行比较,我看不到差异。



< fileset dir =$ {home.dir} / component / libincludes =*。jar/> code>



这一切似乎都是顺序的。
如果我从JUnit测试中调用此方法,从eclipse中运行,没有问题,如果我运行服务器,我得到这个异常。



另外我有另外两个这个组件使用的库我刚把它添加为eclipse&在build.xml中引用的组件lib中,它没有问题。我试着移动罐子,诉诸试验和错误,当逻辑似乎失败了我&没有运气。



为了使事情变得更陌生,我记得现在,我有一些我自己写的代码,甚至没有在图书馆里的这个问题。 java.lang.NoSuchMethodError,因为eclipse偶尔会做随机的事情,我只是改变了方法的名称,并做了一个干净的&它的工作。



我已经尝试清理和重建整个网络应用程序多次,没有变化。



我想要一些关于如何更接近问题的建议,所以我可以尝试找到这个错误,一个调试类路径问题是否还有其他类除了构建文件之外的类路径?



任何关于如何指出问题的建议将不胜感激。



异常:java.lang.NoSuchMethodError
[java]消息:com.google.common.collect.ImmutableMultimap.of()Lcom / google / common / collect / ImmutableMultimap;
[java] ----堆栈跟踪------------------------------------- --------------------------
[java] java.lang.NoSuchMethodError:com.google.common.collect.ImmutableMultimap.of ()LCOM /谷歌/普通/收集/ ImmutableMultimap;
[java] com.google.gdata.util.common.net.UriParameterMap。< clinit>(UriParameterMap.java:78)
[java] com.google.gdata.client.Service.computeQueryMap (Service.java:2190)
[java] com.google.gdata.client.Service.access $ 000(Service.java:94)
[java] com.google.gdata.client.Service $ ClientStreamProperties。< init>(Service.java:1839)
[java] com.google.gdata.client.Service $ ClientOutputProperties。< init>(Service.java:1986)
[java] com.google.gdata.client.Service.writeRequestData(Service.java:2029)
[java] com.google.gdata.client.Service.insert(Service.java:1408)
[java] com.google.gdata.client.GoogleService.insert(GoogleService.java:599)
[java] com.google.gdata.client.appsforyourdomain.AppsForYourDomainService.insert(AppsForYourDomainService.java:100)
[ java] za.co.venturenet.api.googleapps.GoogleAppsServices.createUser(GoogleAppsServices.java:437)
[java] za.co.venturenet.api.googlea pps.GoogleAppsServices.createUser(GoogleAppsServices.java:336)
[java] za.co.venturenet.api.googleapps.GoogleAppsFacade.createNewVenturenetUser(GoogleAppsFacade.java:158)

解决方案

NoSuchMethodError意味着找到该类,但找不到该类中的引用方法。最常见的原因是访问错误版本的类/库。由于您的问题仅在服务器上运行时才会显示,因此我将查看服务器的配置。也许不同的版本,这个库被连接到服务器的系统类加载器(这将在你的webapp中绑定的任何东西)。


I've been battling with this bug for 3 hours. I have checked the build path and classpath and they are the same, this is quite a large webapp, running on Tomcat & Geronimo, it has a build file for each component & then one main once that binds them all together, but I've gone over the ant build files & compared them to others in working components that rely on 3rd party libraries and I don't see an differences.

<fileset dir="${home.dir}/component/lib" includes="*.jar"/>

It all seems to be in order. If I call this method from a JUnit test, run from within eclipse, is passes no problem, if I run the server I get this exception.

Also I have two other libraries that this component uses & I just added it as a user library in eclipse & in the components lib referenced in the build.xml and it works without a problem. I've tried moving jars around resorting to trial and error when logic seemed to fail me & no luck yet.

To make matters even stranger, I remember now, I had this issue with some code I wrote myself that wasn't even in a library. java.lang.NoSuchMethodError, since eclipse does occasionally do random things I just changed the method name and did a clean & it worked.

I've tried cleaning and rebuilding the whole web app several times with no change.

I'd like some advice about how to get closer to the problem so I can try find the bug, how does one debug classpath issues is there anywhere else the classpath is defened besides the build file?

Any suggestions on how to pin point the problem would be appreciated.

Exception: java.lang.NoSuchMethodError [java] Message: com.google.common.collect.ImmutableMultimap.of()Lcom/google/common/collect/ImmutableMultimap; [java] ---- stack trace --------------------------------------------------------------- [java] java.lang.NoSuchMethodError: com.google.common.collect.ImmutableMultimap.of()Lcom/google/common/collect/ImmutableMultimap; [java] com.google.gdata.util.common.net.UriParameterMap.<clinit>(UriParameterMap.java:78) [java] com.google.gdata.client.Service.computeQueryMap(Service.java:2190) [java] com.google.gdata.client.Service.access$000(Service.java:94) [java] com.google.gdata.client.Service$ClientStreamProperties.<init>(Service.java:1839) [java] com.google.gdata.client.Service$ClientOutputProperties.<init>(Service.java:1986) [java] com.google.gdata.client.Service.writeRequestData(Service.java:2029) [java] com.google.gdata.client.Service.insert(Service.java:1408) [java] com.google.gdata.client.GoogleService.insert(GoogleService.java:599) [java] com.google.gdata.client.appsforyourdomain.AppsForYourDomainService.insert(AppsForYourDomainService.java:100) [java] za.co.venturenet.api.googleapps.GoogleAppsServices.createUser(GoogleAppsServices.java:437) [java] za.co.venturenet.api.googleapps.GoogleAppsServices.createUser(GoogleAppsServices.java:336) [java] za.co.venturenet.api.googleapps.GoogleAppsFacade.createNewVenturenetUser(GoogleAppsFacade.java:158)

解决方案

NoSuchMethodError means that the class was found, but a referenced method in that class is not found. The most typical cause of this is accessing a wrong version of class/library. Since your problem only manifests when running on the server, I would look at your server's configuration. Perhaps a different version this library is wired into server's system classloader (which would be ahead of whatever is bundled in your webapp).

这篇关于神秘的NoSuchMethodError&amp;它不能是classpath ...可以吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆