0

I just convert project from simple Java web app to Maven project. And try to run this project using goal mvn tomcat7:run and appropriate plugin

<plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <path>/</path>
                </configuration>
            </plugin>

My project doesn't have standart Maven layout structure that's why I change my build settings in pom

<build>
        <sourceDirectory>src</sourceDirectory>
        <resources>
            <resource>
                <directory>src</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <warSourceDirectory>WebContent</warSourceDirectory>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <path>/</path>
                </configuration>
            </plugin>
        </plugins>
    </build>

Every time when I try to run project I get next error

java.lang.IllegalArgumentException: Document base <path-to-app>\src\main\webapp does not exist or is not a readable directory
    at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:138)
    at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4912)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5092)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)

Please, help me understand why I get this error (I even delete Server folder in Tomcat)

2
  • where did you keep your jsp /html files? They should go in src/main/webapp directory by maven conventions.
    – Adi
    Commented Sep 2, 2014 at 14:47
  • @Adi I keep jsp in WebContent and as I understand <warSourceDirectory>WebContent</warSourceDirectory> this row helps to ovveride default webapp folder location
    – Ray
    Commented Sep 2, 2014 at 14:52

1 Answer 1

3

Maven is waiting specific directory layout to "understand" your project. For example, must commons are :

src/main/java

src/main/resources

src/test/java

I had the same issue as you do. I moved META-INF and WEB-INF into src/main/webapp and deleted the WebContent directory. I added source directories mentioned before too and it works.

You can see more about the standard directory layout for maven: here

Hope it helps you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.