0

My webapp is working properly when manually deployed to Tomcat. I want to perform integration tests during build and I want to use tomcat7-maven-plugin to start embedded tomcat to which webapp will be deployed.

Configuration in pom.xml:

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.1</version>
    <configuration>
        <path>/${name}</path>
    </configuration>
    <executions>
        <execution>
            <id>start-tomcat</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
        <execution>
            <id>stop-tomcat</id>
            <phase>post-integration-test</phase>
            <goals>
                <goal>shutdown</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Tomcat is starting but then error appears:

org.springframework.beans.factory.BeanInitializationException: 
   Could not load properties; nested exception is java.io.FileNotFoundException: 
   Could not open ServletContext resource [/WEB-INF/conf/configuration.properties]

/WEB-INF/conf/configuration.properties is present in war file. Application works correctly when war is deployed to standalone Tomcat instance.

Any ideas what can cause that Spring cannot find configuration file, which is present in war?

Michał Herman
  • 3,437
  • 6
  • 29
  • 43

1 Answers1

0

/WEB-INF/conf is not in the CLASSPATH; /WEB-INF/classes is. Try putting your .properties file there and see if you do better.

If that doesn't work, I'd wonder if it's a class loader hierarchy problem. Java EE containers have a hierarchy of class loaders: first is the bootstrap, second is the app server, last is the application. It might be that you have the .properties file in the application loader when it's needed at the app server level.

duffymo
  • 305,152
  • 44
  • 369
  • 561