Spring Loaded has been working fine for me until I recently switched to deploy as root. (to completely get rid of the "/site" in the URLs of my website)
I've modified the original config brought up by Jeroen here but it's not working.
(The files under ${project.basedir}/target/tomcat7x/webapps/ROOT
is not updated and the website is referring to this outdated source instead of the up-to-date ${project.basedir}/site/target/ROOT
)
What am I missing?
My ${project.basedir}/pom.xml
:
<profile>
<id>cargo.run</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-tomcat-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/contexts</outputDirectory>
<resources>
<resource>
<directory>conf</directory>
<includes>
<include>*-context.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<configuration>
<properties>
<cargo.jvmargs>-Xmx1920m -Xdebug -Xrunjdwp:transport=dt_socket,address=${cargo.debug.address},server=y,suspend=${cargo.debug.suspend} -noverify -javaagent:/Users/eric/libs/springloaded.jar ${cargo.jvm.args}</cargo.jvmargs>
</properties>
<configfiles>
<configfile>
<file>${project.build.directory}/contexts/site-context.xml</file>
<todir>conf/Catalina/localhost/</todir>
<tofile>site.xml</tofile>
</configfile>
</configfiles>
</configuration>
</configuration>
</plugin>
...
</plugins>
</build>
</profile>
My ${project.basedir}/site/pom.xml
<finalName>ROOT</finalName>
...
<plugin>
<groupId>com.googlecode.mavenfilesync</groupId>
<artifactId>maven-filesync-plugin</artifactId>
<configuration>
<mappings>
<mapping>
<sourceFolder>src/main/resources</sourceFolder>
<destinationFolder>@../target/tomcat${cargo.tomcat.major.version}x/webapps/site/WEB-INF/classes</destinationFolder>
</mapping>
<mapping>
<sourceFolder>src/main/webapp</sourceFolder>
<destinationFolder>@../target/tomcat${cargo.tomcat.major.version}x/webapps/site</destinationFolder>
</mapping>
</mappings>
</configuration>
</plugin>
${project.basedir}/conf/site-context.xml
(I've tried having both path as empty string and "/" and neither works)
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/" docBase="${project.basedir}/site/target/ROOT">
<Loader className="org.apache.catalina.loader.VirtualWebappLoader" searchVirtualFirst="true"
virtualClasspath="${project.basedir}/site/target/classes" />
</Context>
Because you renamed the deployed application to ROOT you might need to also change the name of the site-context.xml to ROOT.xml. According to the Tomcat context docs it's required to match the war files name.
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<configuration>
<properties>
<cargo.jvmargs>-Xmx1920m -Xdebug -Xrunjdwp:transport=dt_socket,address=${cargo.debug.address},server=y,suspend=${cargo.debug.suspend} -noverify -javaagent:/Users/eric/libs/springloaded.jar ${cargo.jvm.args}</cargo.jvmargs>
</properties>
<configfiles>
<configfile>
<file>${project.build.directory}/contexts/site-context.xml</file>
<todir>conf/Catalina/localhost/</todir>
<tofile>ROOT.xml</tofile>
</configfile>
</configfiles>
</configuration>
</configuration>
</plugin>