Maven – Hot code deploy tomcat with Maven

maventomcat

I have a web application built using maven. It is built in the form of different projects, that depend on each other – domain, dao, services etc. I ran eclipse:eclipse in each of them to configure my eclipse environment. So now I have multiple projects in eclipse. This is my development environement.

I also built a tomcat bundle for the Operations guys so I can just provide them with a zip file which they can extract and run a batch file to start the server up. This zip file contains a war file which is referred to in the <context> configuration for tomcat.

Also, for development purposes, I have set tomcat to start up from within eclipse. My aim is to do hot code deploy whenever the source changes. This doesnt happen currently because the class files live in the "target" folder(due to maven's directory structure). And tomcat looks at the war file(exploded structure i mean..)

How can i configure my tomcat/eclipse enviroment so I can start doing hot code deploy?

-thanks!

Best Answer

I use the tomcat-maven-plugin and its goal tomcat7:run to start tomcat from within eclipse (btw using m2e plugin for eclipse - great tool - available from eclipse market place). Hot code replacement doesn't work for me, too. But I use a workaround: with <contextReloadable>true</contextReloadable> tomcat reloads the application whenever it detects a file change.

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <path>/myapp</path>
                <contextReloadable>true</contextReloadable>
            </configuration>
        </plugin>
    </plugins>
</build>