Tomcat VirtualWebappLoader 停止工作 Java 类

Tomcat VirtualWebappLoader stopped working for Java classes

直到昨天,它对我来说一直很有效。我在我的 Hippo CMS 项目中将它与 SpringLoaded 一起使用。

症状:
- 适用于对 .ftl 文件的更改 - 不适用于 java classes 的更改,例如我的联系人表单组件

一些发现:

问题是为什么会突然发生?

请注意,没有任何异常或错误!

我昨天做的一件事是在 Cargo 设置下增加 JVM 的内存:

<cargo.jvmargs>-Xmx1920m</cargo.jvmargs>  

这是因为我的存储库很大,如果不提供 Java 更多内存,我将无法 运行 该站点。这会是罪魁祸首吗?

Maven 日志(mvn verify inside /site/ 目录):

➜  site git:(master) ✗ mvn verify
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building SCC Site 2.01.34-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- buildnumber-maven-plugin:1.2:create (default) @ scc-site ---
[INFO] Checking for local modifications: skipped.
[INFO] Updating project files from SCM: skipped.
[INFO] Executing: /bin/sh -c cd /Users/eric/hippo/scc2/site && svn --non-interactive info
[INFO] Working directory: /Users/eric/hippo/scc2/site
[INFO] Storing buildNumber: -1 at timestamp: 1429636391442
[INFO] Executing: /bin/sh -c cd /Users/eric/hippo/scc2/site && svn --non-interactive info
[INFO] Working directory: /Users/eric/hippo/scc2/site
[INFO] Storing buildScmBranch: UNKNOWN_BRANCH
[INFO] 
[INFO] --- maven-filesync-plugin:1.0.0:generate (default) @ scc-site ---
[INFO] No Eclipse .project file found. First import the maven project in Eclipse.
[INFO] 
[INFO] --- maven-remote-resources-plugin:1.5:process (default) @ scc-site ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ scc-site ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] Copying 7 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ scc-site ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 48 source files to /Users/eric/hippo/scc2/site/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ scc-site ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ scc-site ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.16:test (default-test) @ scc-site ---
[INFO] 
[INFO] --- maven-war-plugin:2.4:war (default-war) @ scc-site ---
[INFO] Packaging webapp
[INFO] Assembling webapp [scc-site] in [/Users/eric/hippo/scc2/site/target/site]
[INFO] Processing war project
[INFO] Copying webapp resources [/Users/eric/hippo/scc2/site/src/main/webapp]
[INFO] Webapp assembled in [3505 msecs]
[INFO] Building war: /Users/eric/hippo/scc2/site/target/site.war
[INFO] 
[INFO] --- maven-source-plugin:2.2.1:jar-no-fork (attach-sources) @ scc-site ---
[INFO] Building jar: /Users/eric/hippo/scc2/site/target/site-sources.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.229 s
[INFO] Finished at: 2015-04-22T01:13:28+08:00
[INFO] Final Memory: 20M/215M
[INFO] ------------------------------------------------------------------------

我的主要pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.onehippo.cms7</groupId>
        <artifactId>hippo-cms7-release</artifactId>
        <version>7.9.6</version>
    </parent>

    <name>SCC</name>
    <description>SCC</description>
    <groupId>com.abc</groupId>
    <artifactId>scc</artifactId>
    <version>2.01.34-SNAPSHOT</version>
    <packaging>pom</packaging>

    <!--
      The below project elements are emptied/overridden as otherwise their metadata would be
      inherited or merged from the parent hippo-cms7-release pom (or its hippo-cms7-project pom).

      DO NOT remove these tags but instead fill them in appropriately as needed,
      UNLESS the inherited values are valid for your project.
    -->
    <url/>
    <inceptionYear/>
    <organization/>
    <licenses>
        <license/>
    </licenses>
    <mailingLists>
        <mailingList/>
    </mailingLists>
    <developers>
        <developer/>
    </developers>
    <contributors>
        <contributor/>
    </contributors>
    <issueManagement/>
    <!--
    <scm>
      <connection/>
      <developerConnection/>
      <url/>
    </scm>
    -->
    <ciManagement/>

    <!-- End of emptied/overridden metadata from parent hippo-cms7-release pom. -->

    <properties>

        <!--***START temporary override of versions*** -->
        <hippo.cms.version>2.26.13</hippo.cms.version>
        <!-- ***END temporary override of versions*** -->
        <hippo.hst.version>2.28.09</hippo.hst.version>

        <essentials.version>1.02.06</essentials.version>
        <jsp-api.version>2.1</jsp-api.version>
        <jstl.version>1.1.2</jstl.version>
        <taglibs.version>1.1.2</taglibs.version>
        <commons.lang.version>2.6</commons.lang.version>
        <junit.version>4.10</junit.version>
        <easymock.version>3.1</easymock.version>

        <filesync.override>false</filesync.override>
        <maven.plugins.filesync.version>1.0.0</maven.plugins.filesync.version>
        <repo.bootstrap>true</repo.bootstrap>

    </properties>

    <repositories>
        <repository>
            <id>hippo</id>
            <name>Hippo maven 2 repository.</name>
            <url>https://maven.onehippo.com/maven2/</url>
        </repository>
    </repositories>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.onehippo.cms7.essentials.sdk</groupId>
                <artifactId>api</artifactId>
                <version>${essentials.version}</version>
            </dependency>
            <dependency>
                <groupId>org.onehippo.cms7.essentials.components</groupId>
                <artifactId>cms</artifactId>
                <version>${essentials.version}</version>
            </dependency>
            <dependency>
                <groupId>org.onehippo.cms7.essentials.components</groupId>
                <artifactId>hst</artifactId>
                <version>${essentials.version}</version>
            </dependency>

            <!-- other predefined runtime scope versioned dependencies -->
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>jstl</artifactId>
                <version>${jstl.version}</version>
                <scope>runtime</scope>
            </dependency>

            <dependency>
                <groupId>taglibs</groupId>
                <artifactId>standard</artifactId>
                <version>${taglibs.version}</version>
                <scope>runtime</scope>
            </dependency>

            <!-- other predefined compile scope versioned dependencies -->
            <dependency>
                <groupId>commons-lang</groupId>
                <artifactId>commons-lang</artifactId>
                <version>${commons.lang.version}</version>
            </dependency>

            <dependency>
                <groupId>org.freemarker</groupId>
                <artifactId>freemarker</artifactId>
                <version>${freemarker.version}</version>
            </dependency>

            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>${junit.version}</version>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>org.easymock</groupId>
                <artifactId>easymock</artifactId>
                <version>${easymock.version}</version>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>org.easymock</groupId>
                <artifactId>easymockclassextension</artifactId>
                <version>2.5.2</version>
                <scope>test</scope>
                <exclusions>
                    <exclusion>
                        <groupId>cglib</groupId>
                        <artifactId>cglib-nodep</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

            <dependency>
                <groupId>org.onehippo.cms7.hst</groupId>
                <artifactId>hst-mock</artifactId>
                <version>${hippo.hst.version}</version>
                <scope>test</scope>
            </dependency>

        </dependencies>
    </dependencyManagement>
    <dependencies>
        <!--<dependency>-->
        <!--<groupId>mysql</groupId>-->
        <!--<artifactId>mysql-connector-java</artifactId>-->
        <!--<version>5.1.30</version>-->
        <!--<scope>provided</scope>-->
        <!--</dependency>-->
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>twbs</exclude>
                </excludes>
            </resource>
        </resources>
        <defaultGoal>package</defaultGoal>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.googlecode.mavenfilesync</groupId>
                    <artifactId>maven-filesync-plugin</artifactId>
                    <version>${maven.plugins.filesync.version}</version>
                    <configuration>
                        <override>${filesync.override}</override>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>generate</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>buildnumber-maven-plugin</artifactId>
                <version>${maven.plugin.buildnumber.version}</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>create</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <doCheck>false</doCheck>
                    <doUpdate>false</doUpdate>
                    <revisionOnScmFailure>-1</revisionOnScmFailure>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>${maven.plugin.jar.version}</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                        <manifestEntries>
                            <Implementation-Build>${buildNumber}</Implementation-Build>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>

        </plugins>
        <extensions>
            <!-- Enabling the use of SSH -->
            <extension>
                <groupId>org.apache.maven.wagon</groupId>
                <artifactId>wagon-ssh-external</artifactId>
                <version>1.0-beta-6</version>
            </extension>
        </extensions>
    </build>

    <profiles>

        <profile>
            <id>default</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <property>
                    <name>jrebel</name>
                </property>
            </activation>
            <modules>
                <module>bootstrap</module>
                <module>cms</module>
                <module>site</module>
                <module>essentials</module>
            </modules>
        </profile>

        <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>
                                    <catalina.servlet.uriencoding>UTF-8</catalina.servlet.uriencoding>
                                    <cargo.jvmargs>-Xmx1920m</cargo.jvmargs>
                                </properties>
                                <configfiles>
                                    <!--<configfile>-->
                                    <!--<file>${project.basedir}/conf/context.xml</file>-->
                                    <!--<todir>conf/</todir>-->
                                    <!--<tofile>context.xml</tofile>-->
                                    <!--</configfile>-->
                                    <configfile>
                                        <file>${project.build.directory}/contexts/site-context.xml</file>
                                        <todir>conf/Catalina/localhost/</todir>
                                        <tofile>site.xml</tofile>
                                    </configfile>
                                </configfiles>
                            </configuration>
                            <deployables>
                                <deployable>
                                    <type>war</type>
                                    <properties>
                                        <context>/cms</context>
                                    </properties>
                                    <location>${project.basedir}/cms/target/cms.war</location>
                                </deployable>
                                <deployable>
                                    <location>${project.basedir}/site/target/site.war</location>
                                    <type>war</type>
                                    <properties>
                                        <context>/site</context>
                                    </properties>
                                </deployable>
                                <deployable>
                                    <location>${project.basedir}/essentials/target/essentials.war</location>
                                    <type>war</type>
                                    <properties>
                                        <context>/essentials</context>
                                    </properties>
                                </deployable>
                            </deployables>
                            <container>
                                <systemProperties>
                                    <derby.stream.error.file>${project.basedir}/target/derby.log
                                    </derby.stream.error.file>
                                    <log4j.configuration>file:${project.basedir}/conf/log4j-dev.xml
                                    </log4j.configuration>
                                    <rebel.log4j-plugin>true</rebel.log4j-plugin>
                                    <!-- enables auto export: -->
                                    <project.basedir>${project.basedir}</project.basedir>
                                    <!--<repo.config>file:${project.basedir}/conf/repository.xml</repo.config>-->
                                </systemProperties>
                                <!--<dependencies>-->
                                <!--<dependency>-->
                                <!--<groupId>mysql</groupId>-->
                                <!--<artifactId>mysql-connector-java</artifactId>-->
                                <!--<classpath>extra</classpath>-->
                                <!--</dependency>-->
                                <!--</dependencies>-->
                            </container>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>dist</id>
            <dependencies>
                <dependency>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>org.slf4j</groupId>
                    <artifactId>jcl-over-slf4j</artifactId>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                    <scope>provided</scope>
                </dependency>
            </dependencies>
            <build>
                <defaultGoal>validate</defaultGoal>
                <plugins>
                    <plugin>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>distro-assembly</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <configuration>
                                    <descriptors>
                                        <descriptor>${project.basedir}/src/main/assembly/distribution.xml</descriptor>
                                    </descriptors>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>springloaded</id>
            <activation>
                <property>
                    <name>springloaded</name>
                </property>
            </activation>
            <properties>
                <javaagent>-javaagent:/Users/eric/libs/springloaded.jar</javaagent>
            </properties>
        </profile>

    </profiles>

</project>

原来是 cargo.jvmargs 弄坏了它。 javaagent SpringLoaded 似乎被这种方式忽略了。

所以我对 ${project.basedir}/pom.xml 进行了以下更改,SpringLoaded 再次运行:

<properties>
    <javaagent>-javaagent:/Users/eric/libs/springloaded.jar</javaagent>
</properties>
...
<profiles>
    <profile>
        <id>cargo.run</id>
        <build>
            <plugins>
                <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} ${cargo.jvm.args}</cargo.jvmargs> 

如果没有完整的 jvmargs,调试也会停止工作。

以上在Hippo CMS documentation中也有提及。我不得不把它挖出来。