开发者

Mysterious NoSuchMethodError & it can't be the classpath...can it?

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.j开发者_高级运维ava: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).


>since eclipse does occasionally do random things I just changed the method name and did a clean & it worked.

I've had the same error, and have tried the same solution: change method name, or add an empty line to the java file, rebuild. It usually works one time. But upon second server start, the NoSuchMethodError returns for the same method identifier.

My eclipse environment builds a "target/classes" folder, which gets a copy of the web-inf classes. Removal of that folder seems to have cured my problems with random NoSuchMethodError, which were probably caused by inability to resolve which instance to load.

Your mileage may vary.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜