contextConfigLocation in web.xml creates an IO exception when using intellij

I'm not sure what Intellij does but this seems to work in eclipse without issues.I register a context loader listener and point the classpath to a directory but I get this -> java.io.FileNotFoundException: class path resource [src/main/resources/com/myapp/config/dao-context.xml] cannot be opened because it does not exist. Intellij's code completion seems to find it just fine as I type the path and file. Anyone have any clue why this isn't working?

<web-app version="2.4"
    xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <display-name>Spring MVC Application</display-name>

    <servlet>
        <servlet-name>mvc-dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>mvc-dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <resource-ref>
        <description>DB Connection</description>
        <res-ref-name>jdbc/spring</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>

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

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath:com/corejunk/config/dao-context.xml
        </param-value>
    </context-param>

</web-app>

1 comment

Nevermind, I went into Edit Configurations - Tomcat Server - Deployment and changed the application context to the actual context of the project and it fixed it. I think jetbrains.tv ought to do a video on how to configure exploded deployments for popular containers such as tomcat and jboss. It should also explain the ramifications of what happens when you take the defaults.

0

Please sign in to leave a comment.