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 6796859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:32:18+00:00 2026-05-26T18:32:18+00:00

I am trying to test my application with junit. Therefore I’ve setup the following

  • 0

I am trying to test my application with junit.

Therefore I’ve setup the following class:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "/META-INF/spring/applicationContext-test.xml" )
@TransactionConfiguration
@Transactional
public class DispatcherServletTest extends AbstractJUnit4SpringContextTests {

    private MockHttpServletRequest request;
    private MockHttpServletResponse response;

    private DispatcherServlet dispatcher;

    @Before
    public void setUp() throws Exception {
            request = new MockHttpServletRequest();
            response = new MockHttpServletResponse();

            MockServletConfig config = new MockServletConfig("myapp");
            config.addInitParameter("contextConfigLocation","classpath*:webmvc-config.xml");

            dispatcher = new DispatcherServlet();
            dispatcher.init(config);
    }
    //test cases

}

So the problem is, that it seems that my dispatcher servlet cannot send any request to any of my controllers.

I think that there is something with the configuration – contextConfigurationLocation.
It looks like he can find the file (otherwise it would throw an exception) , but doesn’t load any configuration

The logger says:

org.springframework.web.servlet.PageNotFound – No mapping found for HTTP request with URI [http://localhost:8080/myapp/abc]

But I have absolutely no idea what’s wrong…

I would appreciate any help!

Thanks in advance

  • 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-26T18:32:19+00:00Added an answer on May 26, 2026 at 6:32 pm

    Mines are working fine, try the following tweaks.

    1. if you’re using Junit4 no need to extend you test class, the junit runner should do the trick
    2. Load the context config via classpath, and make sure is accessible from the test classpath

      @ContextConfiguration(locations={“classpath:applicationContext-test.xml”})

    3. then just test the annotated controllers. I do it like this:

    
        @Test
        @Transactional
        public void testAnnotatedListUser() throws Exception {
            MockHttpServletRequest request = new MockHttpServletRequest();
            MockHttpServletResponse response = new MockHttpServletResponse();
            AnnotationMethodHandlerAdapter handlerAdpt = new AnnotationMethodHandlerAdapter();
            request.setRequestURI("/you/URIhere");
            ModelAndView mav = handlerAdpt.handle(request, response, this.controller);
            assertEquals("Incorrect view name returned", "myexpectedviewname", mav.getViewName());
        }
    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I am trying to test a RESTful Application, but keep getting the following
I'm trying to create my first test application with NHibernate following example in NHibernate
I am trying to JUnit Test a J2EE Web Application with NB 7.0, JUnit
I am trying to create a test application the source is the following (index.php):
I am trying to test my application on facebook. But i keep getting the
I'm trying to test an application and I need to make an valid IP
I have been trying to test my application to make sure that all the
I am still trying to test my WinForm application, however some of the testing
Alright, I'm trying to get arguments to work properly with a small test application.
I'm trying to test a method I have in my application, but I don't

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.