Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3402496
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:08:42+00:00 2026-05-18T05:08:42+00:00

I have a unit test that uses the hamcrest library (1.2). It’s important that

  • 0

I have a unit test that uses the hamcrest library (1.2). It’s important that it’s 1.2 because I want to include a namespace context in the hasXPath matcher. This is a maven project and I have all my dependencies set up to work correctly. (I make sure that I only use junit-dep and not junit – a pain but I’ve confirmed that my dependency tree is correct.) Everything works fine in maven. However, when I run the same test in eclipse (3.6) I get the following error:

java.lang.NoSuchMethodError: org.hamcrest.Matchers.hasXPath(Ljava/lang/String;Ljavax/xml/namespace/NamespaceContext;Lorg/hamcrest/Matcher;)Lorg/hamcrest/Matcher;
    at com.factorlab.ws.obs.meta.PhenomononGroupsResourceITest.testGetPhenomenonGroupsXml(PhenomononGroupsResourceITest.java:36)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

I have double-checked my eclipse build path configuration for the project and it also has junit-dep and no junit and hamcrest 1.2. Furthermore, there are no compile errors, so this is just a runtime thing. Does eclipse have a runtime of it’s own that’s interfering here? How can I work around this?

The code that is causing the exception is 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 a ton of context – i.e. the web service code, the full class code, dependent classes like MetaNamespaceContext, etc. However, I am confident that since this all works when I do a mvn clean install from the command line, it must be an eclipse configuration issue and have little to do with the specific code being run. (Except, of course, that the hasXPath(String, NamespaceContext, Matcher) method is only available in 1.2 and everything would work fine if I just used hasXPath(String, Matcher).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T05:08:43+00:00Added an answer on May 18, 2026 at 5:08 am

    I fixed this by configuring my build path and moving the hacrest 1.2 libraries to the top of the order. Of course, if I ever do a mvn eclipse:eclipse again, I have to go in and fix it again, so it’s not a terribly nice solution, but it works for now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.