Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » JUnit launch gives a NoSuchMethodError but the method really exists
JUnit launch gives a NoSuchMethodError but the method really exists [message #250092] Sat, 08 December 2007 00:35 Go to next message
Eclipse UserFriend
I am testing a class which uses Hibernate Search and when I run the JUnit
test within Eclipse I get a NoSuchMethodError, although the method
reported as missing does in fact exist (see
http://www.hibernate.org/hib_docs/search/api/org/hibernate/s earch/FullTextSession.html#createFullTextQuery(org.apache.lucene.search.Query,%20java.lang.Class...)).
If the method really didn't exist then the test class wouldn't even
compile, right?

I have looked into my Maven dependencies and I can see that the class with
this method is present. There is no additional JAR in the classpath for
this test's launch configuration.

The stack trace I get when I run the test is included below. Any
suggestions as to what may be going wrong (or where to look for more
clues) will be very appreciated, thanks in advance.

--James



java.lang.NoSuchMethodError:
org.hibernate.search.FullTextSession.createFullTextQuery(Lor g/apache/lucene/search/Query;[Ljava/lang/Class;)Lorg/hiberna te/search/FullTextQuery;
at
com.mycom.model.finder.PayorFinderImplTest.testFindBySearchT ext(PayorFinderImplTest.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java :59)
at
org.junit.internal.runners.MethodRoadie.runTestMethod(Method Roadie.java:98)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.j ava:79)
at
org.junit.internal.runners.MethodRoadie.runBeforesThenTestTh enAfters(MethodRoadie.java:87)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie .java:77)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.jav a:42)
at
org.junit.internal.runners.JUnit4ClassRunner.invokeTestMetho d(JUnit4ClassRunner.java:88)
at
org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUni t4ClassRunner.java:51)
at
org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4Cla ssRunner.java:44)
at
org.junit.internal.runners.ClassRoadie.runUnprotected(ClassR oadie.java:27)
at
org.junit.internal.runners.ClassRoadie.runProtected(ClassRoa die.java:37)
at
org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4Class Runner.java:42)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.r un(JUnit4TestReference.java:38)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main( RemoteTestRunner.java:196)
Re: JUnit launch gives a NoSuchMethodError but the method really exists [message #250134 is a reply to message #250092] Mon, 10 December 2007 14:01 Go to previous messageGo to next message
Eclipse UserFriend
It turned out that the class was being found in another JAR
(hibernate-annotations-3.2.1.jar) which was coming from another project's
pom.xml. I updated the version of that JAR in that pom.xml and the
problem disappeared.

--James
Re: JUnit launch gives a NoSuchMethodError but the method really exists [message #250142 is a reply to message #250134] Mon, 10 December 2007 15:44 Go to previous message
Eclipse UserFriend
Originally posted by: wharley.bea.com

"James Adams" <monocongo@gmail.com> wrote in message
news:22a4c678746cff13ee36b1faba0d31d2$1@www.eclipse.org...
> It turned out that the class was being found in another JAR

That's almost always what NoSuchMethodError means: you're compiling against
a different version of the jar than you're running against.
Previous Topic:How to migrate my customized perspectives
Next Topic:Creating sample projects.
Goto Forum:
  


Current Time: Sun Apr 20 04:00:29 EDT 2025

Powered by FUDForum. Page generated in 0.02871 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top