java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/final-servlet.xml]

17,469

Solution 1

Put the final-servlet.xml under WEB-INF folder and it will works. What you are asking about your application-context.xml i think is something like this:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        WEB-INF/final-servlet.xml
        classpath:application-context.xml
    </param>
</context-param>

Solution 2

Files in the resources directory are deployed to the classpath, not WEB-INF. If you want the file in WEB-INF then it needs to be in src/webapp/WEB-INF, as in any Maven-based web app project.

Otherwise the location referenced in the Spring config needs to be classpath-relative.

Share:
17,469
JOHND
Author by

JOHND

http://www.aonlinetraining.com/online_training_textile_designing_gallery1.html http://www.sasmira.org/courses.htm http://www.birlavidyamandir.com/Careers/institutes_art%20architecture%20photography%20design%20fashion.htm

Updated on June 05, 2022

Comments

  • JOHND
    JOHND almost 2 years

    I am creating simple maven project plugin . Application directory structure is like standard maven project directory structure.

    I have place application-context.xml file under src/main/java/resources folder.

    Problem :

    How to configure this path in web.xml file ?

    I am getting java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/final-servlet.xml] error

    Do i have to configure my project properties in eclipse???

    Can any one guide me on the same....??

    Thanks in advance..>!

    • Dave Newton
      Dave Newton almost 12 years
      Did you mean /src/main/resources? In any case, we don't know how you're trying to access the file, so diagnosing what's gone wrong is difficult.
    • JOHND
      JOHND almost 12 years
      how to access ..?? i dont know . I just created folder structure and welcome file. I am just tasting my framework.
    • JOHND
      JOHND almost 12 years
      when i build and run it using eclipse it gives java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/final-servlet.xml] error On console
    • Dave Newton
      Dave Newton almost 12 years
      We don't know what you're doing. If you're just creating a spring web project put the file in the right location.
    • JOHND
      JOHND almost 12 years
      I am creating plugin project for future reference
  • Admin
    Admin about 10 years
    How can we access these files for BufferedWriter in the Service layer?