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

  • Home
  • SEARCH
  • 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 9020683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:04:56+00:00 2026-06-16T05:04:56+00:00

Following the instructions here , but i get the error unable to autowire WebApplicationContext.

  • 0

Following the instructions here, but i get the error unable to autowire WebApplicationContext.

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("applicationContext-test.xml")
@WebAppConfiguration
public class AjaxTest {

@Autowired
private WebApplicationContext webApplicationContext; //FAILS

But this compiles :

@Autowired
ServletContext servletContext;

private WebApplicationContext webApplicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);

And I don’t understand why.

Edit
It runs fine using maven, it was my editor intellij showing an incorrect auto compile message, a bug in fact.

  • 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-06-16T05:04:57+00:00Added an answer on June 16, 2026 at 5:04 am

    Your test class should implement ApplicationContextAware interface:

    public class ApplicationContextProvider implements ApplicationContextAware {
               private static ApplicationContext applicationContext = null;
    
                public static ApplicationContext getApplicationContext() {
                    return applicationContext;
                }
                public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
                     this.applicationContext = applicationContext;
                }
          }
    

    Spring will automatically inject the application context.

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

Sidebar

Related Questions

I am installing phing using instructions here I get the following error. I have
I created a test hello world Slim app following instructions here . When I
I have been following the RestKit installation instructions but I now have an error
Tried following the instructions here: How to use Google app engine with my own
Anyone out there using the FTUtils library for iPhone development? Following the instructions here
I'm trying to build sbt 0.12.0-RC1 following instructions at https://github.com/harrah/xsbt to the letter, but
Following the instructions here: https://github.com/ry/node/wiki/Building-node.js-on-Cygwin-(Windows ) I've tried installing on two machines, either of
I followed the instructions here to add a library for HTMLParser. However, I get
I am trying to use geokit but I get the following message: undefined method
Basically I have followed the instructions here But when I go to couchbase to

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.