0
votes

I have aded following code to my web.xml

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
    classpath:com/neelamhotel/mavenwebproject5/configs/dao-context.xml
</param-value>

But I am getting error for the same as

IOException parsing XML document from class path resource [com/neelamhotel/mavenwebproject5/configs/dao-context.xml]; nested exception is java.io.FileNotFoundException: class path resource [com/neelamhotel/mavenwebproject5/configs/dao-context.xml] cannot be opened because it does not exist

Project Structure

enter image description here

Explorer View

enter image description here

I know dao-context.xml file is there. But then why it is giving an error ?

Updated Explorer view

enter image description here

Created WAR file view

enter image description here

1
@Jens nope, it is not that. tried it.Meena Chaudhary
can you add a '/' at the start of the resource? classpath:/com/neelamhotel/mavenwebproject5/configs/dao-configs.xml (and try again). Without that, the location is relative to the path from where you're opening the application.Augusto
@Augusto tried not workingMeena Chaudhary
I know dao-configs.xml file is there. How do you know? Where do you look for this file?JB Nizet
@JBNizet I mean I can see it in my source package and that is by default on classpath. So it should be able to find it when I mention classpath when passing param-value.Meena Chaudhary

1 Answers

2
votes

In a Maven project, src/main/java is for Java source files. The other files are ignored by Maven.

Resources (i.e. non-Java files) that must be copied and be available in the classpath must go in src/main/resources.

Gradle uses the same conventions.