close

[Solved] Test java.lang.IllegalStateException: Failed to load ApplicationContext

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Test java.lang.IllegalStateException: Failed to load ApplicationContext in java. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Test java.lang.IllegalStateException: Failed to load ApplicationContext Error Occurs?

Today I get the following error Test java.lang.IllegalStateException: Failed to load ApplicationContext in java.

How To Solve Test java.lang.IllegalStateException: Failed to load ApplicationContext Error ?

  1. How To Solve Test java.lang.IllegalStateException: Failed to load ApplicationContext Error ?

    To Solve Test java.lang.IllegalStateException: Failed to load ApplicationContext Error I added the spring folder to the build path and, after clean&build, it worked.

  2. Test java.lang.IllegalStateException: Failed to load ApplicationContext

    To Solve Test java.lang.IllegalStateException: Failed to load ApplicationContext Error I added the spring folder to the build path and, after clean&build, it worked.

Solution 1

Try with the relative path using *

  @ContextConfiguration(locations = {
"classpath*:spring/applicationContext.xml",
"classpath*:spring/applicationContext-jpa.xml",
"classpath*:spring/applicationContext-security.xml" })

If not look if your xml are really on resources/spring/.

Finally try just on without location

 @ContextConfiguration({"classpath*:spring/applicationContext.xml"})

The other error that you´re showing is because you have this tag duplicated on applicationContext.xml and applicationContext-security.xml

 Duplicate <global-method-security>

Solution 2

I added the spring folder to the build path and, after clean&build, it worked.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read

Leave a Comment