junit4 - NoSuchMethodError: org.hamcrest.Matchers.hasXPath when I run tests in eclipse -


i have unit test uses hamcrest library (1.2). it's important it's 1.2 because want include namespace context in hasxpath matcher. maven project , have dependencies set work correctly. (i make sure use junit-dep , not junit - pain i've confirmed dependency tree correct.) works fine in maven. however, when run same test in eclipse (3.6) following error:

java.lang.nosuchmethoderror: org.hamcrest.matchers.hasxpath(ljava/lang/string;ljavax/xml/namespace/namespacecontext;lorg/hamcrest/matcher;)lorg/hamcrest/matcher;     @ com.factorlab.ws.obs.meta.phenomonongroupsresourceitest.testgetphenomenongroupsxml(phenomonongroupsresourceitest.java:36)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25)     @ java.lang.reflect.method.invoke(method.java:597)     @ org.junit.runners.model.frameworkmethod$1.runreflectivecall(frameworkmethod.java:44)     @ org.junit.internal.runners.model.reflectivecallable.run(reflectivecallable.java:15)     @ org.junit.runners.model.frameworkmethod.invokeexplosively(frameworkmethod.java:41)     @ org.junit.internal.runners.statements.invokemethod.evaluate(invokemethod.java:20)     @ org.junit.runners.blockjunit4classrunner.runchild(blockjunit4classrunner.java:76)     @ org.junit.runners.blockjunit4classrunner.runchild(blockjunit4classrunner.java:50)     @ org.junit.runners.parentrunner$3.run(parentrunner.java:193)     @ org.junit.runners.parentrunner$1.schedule(parentrunner.java:52)     @ org.junit.runners.parentrunner.runchildren(parentrunner.java:191)     @ org.junit.runners.parentrunner.access$000(parentrunner.java:42)     @ org.junit.runners.parentrunner$2.evaluate(parentrunner.java:184)     @ org.junit.runners.parentrunner.run(parentrunner.java:236)     @ org.eclipse.jdt.internal.junit4.runner.junit4testreference.run(junit4testreference.java:49)     @ org.eclipse.jdt.internal.junit.runner.testexecution.run(testexecution.java:38)     @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.runtests(remotetestrunner.java:467)     @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.runtests(remotetestrunner.java:683)     @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.run(remotetestrunner.java:390)     @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.main(remotetestrunner.java:197) 

i have double-checked eclipse build path configuration project , has junit-dep , no junit , hamcrest 1.2. furthermore, there no compile errors, runtime thing. eclipse have runtime of it's own that's interfering here? how can work around this?

the code causing exception here:

private namespacecontext namespacecontext = new metanamespacecontext();  @test public void testgetphenomenongroupsxml() throws exception {     webclient webclient = new webclient();     webclient.addrequestheader("accept", "application/xml");     xmlpage xmlresult = webclient.getpage(base_url);     //printdoc(xmlresult.getxmldocument(), system.out);     assertthat("count of groups",             xmlresult.getxmldocument(),             hasxpath("count(/phenomenongroups/om:phenomenongroup)",                     namespacecontext, equalto("4")));     assertthat("first group",             xmlresult.getxmldocument(),             hasxpath(                     "/phenomenongroups/om:phenomenongroup/om:quickyesnophenomenon/id/text()",                     namespacecontext, equalto("1"))); } 

i'm not sure if that's helpful without ton of context - i.e. web service code, full class code, dependent classes metanamespacecontext, etc. however, confident since works when mvn clean install command line, must eclipse configuration issue , have little specific code being run. (except, of course, hasxpath(string, namespacecontext, matcher) method available in 1.2 , work fine if used hasxpath(string, matcher).

i fixed configuring build path , moving hacrest 1.2 libraries top of order. of course, if ever mvn eclipse:eclipse again, have go in , fix again, it's not terribly nice solution, works now.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -