简体   繁体   English

JHipster Eclipse项目“主”中的内存不足

[英]JHipster Eclipse project running out of memory in “main”

I am building up a baseline JHipster project with no bells and whistles involved (no clustering, etc.). 我正在建立一个基线JHipster项目,其中不涉及任何麻烦(不包含集群等)。 I am following the exact tutorial steps using my standard Node-enabled (of course) command line, and am then importing the project into Eclipse as a Maven Project. 我正在使用我的标准启用节点的命令行(当然)按照确切的教程步骤进行操作,然后将项目作为Maven项目导入到Eclipse中。 Everything looks like it should be working fine based on reviewing the project, except when I try to run it on the server or build it using the mvn command line... 根据我对项目的审查,一切看起来都应该工作正常,除非我尝试在服务器上运行它或使用mvn命令行构建它...

Error Message 错误信息

INFO: Starting Servlet Engine: Apache Tomcat/7.0.12
Exception in thread "main" 
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "main"

POM/Maven POM / Maven的

From what I can tell, this may be a POM dependency error, but if so then I am having a heck of a time figuring out which. 据我所知,这可能是POM依赖项错误,但是如果是这样,那么我将花费大量时间来找出哪个错误。 My project is directly configured to use JRE 1.7. 我的项目直接配置为使用JRE 1.7。 My POM is below. 我的POM在下面。 Another thought is that it is directly related to the original NPM install from Hipster (after POM): 另一个想法是,它与从Hipster(在POM之后)安装的原始NPM直接相关:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.0.0.RC4</version>
</parent>

<profiles>
    <profile>
        <id>dev</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <!-- Spring profile to use -->
            <spring.profiles.active>dev</spring.profiles.active>
            <!-- log configuration -->
            <logback.loglevel>DEBUG</logback.loglevel>
        </properties>
    </profile>
    <profile>
        <id>prod</id>
        <properties>
            <!-- Spring profile to use -->
            <spring.profiles.active>prod</spring.profiles.active>
            <!-- log configuration -->
            <logback.loglevel>INFO</logback.loglevel>
            <logback.appender>CONSOLE</logback.appender>
        </properties>
        <build>
            <plugins>
                <plugin>
                    <groupId>com.github.trecloux</groupId>
                    <artifactId>yeoman-maven-plugin</artifactId>
                    <version>0.1</version>
                    <configuration>
                        <yeomanProjectDirectory>${project.basedir}</yeomanProjectDirectory>
                    </configuration>
                    <executions>
                        <execution>
                            <id>run-grunt</id>
                            <phase>generate-resources</phase>
                            <goals>
                                <goal>build</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>2.5</version>
                    <configuration>
                        <filesets>
                            <fileset>
                                <directory>dist</directory>
                            </fileset>
                            <fileset>
                                <directory>.tmp</directory>
                            </fileset>
                            <fileset>
                                <directory>node_modules</directory>
                            </fileset>
                        </filesets>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <configuration>
                        <arguments>
                            <argument>--spring.profiles.active=prod</argument>
                        </arguments>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

<properties>
    <!-- Maven build properties -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.7</java.version>

    <metrics-spring.version>3.0.0-RC4</metrics-spring.version>
    <HikariCP.version>1.3.3</HikariCP.version>
    <commons-lang.version>2.6</commons-lang.version>
    <commons-io.version>2.4</commons-io.version>
    <javax.inject.version>1</javax.inject.version>
    <joda-time-hibernate.version>1.3</joda-time-hibernate.version>
    <geronimo-javamail_1.4_mail.version>1.8.3</geronimo-javamail_1.4_mail.version>
    <usertype.core.version>3.1.0.CR10</usertype.core.version>
    <springloaded.version>1.2.0.BUILD-20140214.165636-1</springloaded.version>
    <awaitility.version>1.4.0</awaitility.version>
    <json-path.version>0.9.1</json-path.version>
    <assertj-core.version>1.5.0</assertj-core.version>
    <maven-enforcer-plugin.version>1.3.1</maven-enforcer-plugin.version>
    <sonar-maven-plugin.version>2.2</sonar-maven-plugin.version>

    <postgresql.version>9.3-1100-jdbc41</postgresql.version>
</properties>

<repositories>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>http://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>http://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>org.jboss.repository.releases</id>
        <name>JBoss Maven Release Repository</name>
        <url>https://repository.jboss.org/nexus/content/repositories/releases</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-snapshots</id>
        <url>http://repo.spring.io/libs-snapshot</url>
        <snapshots><enabled>true</enabled></snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>spring-milestones</id>
        <url>http://repo.spring.io/milestone</url>
        <snapshots><enabled>true</enabled></snapshots>
    </pluginRepository>
</pluginRepositories>

<prerequisites>
    <maven>3.0.0</maven>
</prerequisites>

<dependencies>
    <dependency>
        <groupId>com.codahale.metrics</groupId>
        <artifactId>metrics-core</artifactId>
    </dependency>
    <dependency>
        <groupId>com.codahale.metrics</groupId>
        <artifactId>metrics-ehcache</artifactId>
        <version>${codahale-metrics.version}</version>
    </dependency>
    <dependency>
        <groupId>com.codahale.metrics</groupId>
        <artifactId>metrics-graphite</artifactId>
    </dependency>
    <dependency>
        <groupId>com.codahale.metrics</groupId>
        <artifactId>metrics-jvm</artifactId>
        <version>${codahale-metrics.version}</version>
    </dependency>
    <dependency>
        <groupId>com.codahale.metrics</groupId>
        <artifactId>metrics-servlet</artifactId>
        <version>${codahale-metrics.version}</version>
    </dependency>
    <dependency>
        <groupId>com.codahale.metrics</groupId>
        <artifactId>metrics-servlets</artifactId>
        <exclusions>
            <exclusion>
                <groupId>com.codahale.metrics</groupId>
                <artifactId>metrics-healthchecks</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.datatype</groupId>
        <artifactId>jackson-datatype-json-org</artifactId>
        <version>${jackson.version}</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.datatype</groupId>
        <artifactId>jackson-datatype-hppc</artifactId>
        <version>${jackson.version}</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.datatype</groupId>
        <artifactId>jackson-datatype-joda</artifactId>
    </dependency>
    <dependency>
        <groupId>com.ryantenney.metrics</groupId>
        <artifactId>metrics-spring</artifactId>
        <version>${metrics-spring.version}</version>
    </dependency>
    <dependency>
        <groupId>com.zaxxer</groupId>
        <artifactId>HikariCP</artifactId>
        <version>${HikariCP.version}</version>
        <exclusions>
            <exclusion>
                <groupId>com.sun</groupId>
                <artifactId>tools</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <!-- The HikariCP Java Agent is disabled by default, as it is experimental
    <dependency>
        <groupId>com.zaxxer</groupId>
        <artifactId>HikariCP-agent</artifactId>
        <version>1.3.0</version>
    </dependency>
    -->
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>${commons-lang.version}</version>
    </dependency>
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>${commons-io.version}</version>
    </dependency>
    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>${javax.inject.version}</version>
    </dependency>
    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
    </dependency>
    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time-hibernate</artifactId>
        <version>${joda-time-hibernate.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.geronimo.javamail</groupId>
        <artifactId>geronimo-javamail_1.4_mail</artifactId>
        <version>${geronimo-javamail_1.4_mail.version}</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>${hibernate-entitymanager.version}</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-ehcache</artifactId>
        <version>${hibernate-entitymanager.version}</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.jadira.usertype</groupId>
        <artifactId>usertype.core</artifactId>
        <version>${usertype.core.version}</version>
    </dependency>
    <dependency>
        <groupId>org.liquibase</groupId>
        <artifactId>liquibase-core</artifactId>
    </dependency>
    <dependency>
        <groupId>org.liquibase.ext</groupId>
        <artifactId>liquibase-hibernate4</artifactId>
        <version>3.3</version>
        <exclusions>
            <exclusion>
                <groupId>org.hibernate.javax.persistence</groupId>
                <artifactId>hibernate-jpa-2.0-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-autoconfigure</artifactId>
        <version>${spring-boot.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-loader-tools</artifactId>
        <version>${spring-boot.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-logging</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-aop</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springsource.loaded</groupId>
        <artifactId>springloaded</artifactId>
        <version>${springloaded.version}</version>
        <scope>provided</scope>
    </dependency>       

    <!-- Database dependencies-->
    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.3-1100-jdbc41</version>
    </dependency>


    <!-- Test dependencies -->
    <dependency>
        <groupId>com.jayway.awaitility</groupId>
        <artifactId>awaitility</artifactId>
        <version>${awaitility.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.jayway.jsonpath</groupId>
        <artifactId>json-path</artifactId>
        <version>${json-path.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-core</artifactId>
        <version>${assertj-core.version}</version>
        <scope>test</scope>
    </dependency>
</dependencies>
<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
            <includes>
                <include>**/*</include>
            </includes>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-enforcer-plugin</artifactId>
            <version>${maven-enforcer-plugin.version}</version>
            <executions>
                <execution>
                    <id>enforce-versions</id>
                    <goals>
                        <goal>enforce</goal>
                    </goals>
                    <configuration>
                        <rules>
                            <requireMavenVersion>
                                <message>You are running an older version of Maven. JHipster requires at least Maven 3.0</message>
                                <version>[3.0.0,)</version>
                            </requireMavenVersion>
                            <requireJavaVersion>
                                <message>You are running an older version of Java. JHipster requires at least JDK 1.7</message>
                                <version>[1.7.0,)</version>
                            </requireJavaVersion>
                        </rules>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <argLine>-XX:MaxPermSize=128m -Xmx256m</argLine>
                <forkCount>1</forkCount>
                <reuseForks>false</reuseForks>
                <!-- Force alphabetical order to have a reproducible build -->
                <runOrder>alphabetical</runOrder>
                <classpathDependencyExcludes>
                    <classpathDependencyExclude>org.springsource.loaded:springloaded</classpathDependencyExclude>
                </classpathDependencyExcludes>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <packagingExcludes>WEB-INF/lib/tomcat-*.jar</packagingExcludes>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-eclipse-plugin</artifactId>
            <configuration>
                <downloadSources>true</downloadSources>
                <downloadJavadocs>true</downloadJavadocs>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>sonar-maven-plugin</artifactId>
            <version>${sonar-maven-plugin.version}</version>
        </plugin>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <arguments>
                    <argument>--spring.profiles.active=dev</argument>
                </arguments>
            </configuration>
        </plugin>
    </plugins>
</build>

NPM NPM

Looking at what is being responded by NPM at initial JHipster generation, I am actually seeing errors in those logs as well, noted below. 看看最初的JHipster一代中NPM的响应,我实际上也看到了这些日志中的错误,如下所述。 Does anyone have any background on this? 有人对此有背景吗?

2400 verbose etag pad-stdio from cache
2401 error Error: No compatible version found: findup-sync@'^0.1.2'
2401 error Valid install targets:
2401 error ["0.1.0","0.1.1","0.1.2","0.1.3"]
2401 error     at installTargetsError (C:\ProgramFiles\nodejs\node_modules\npm\lib\cache.js:719:10)
2401 error     at C:\Program Files\nodejs\node_modules\npm\lib\cache.js:638:10
2401 error     at saved (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\get.js:142:7)

Even with this error, I was able to manually include findup-sync with a direct npm install findup-sync@0.1.2 , but this did not resolve my error with the Tomcat instance. 即使出现此错误,我也可以通过直接npm install findup-sync@0.1.2手动包含findup-sync,但这不能解决Tomcat实例的错误。

Back to Maven/POM 返回Maven / POM

It must be something else specifically to do with com.sun:tools.jar... Looking through my POM, but if anyone has experienced this before with JHipster, please give me a shout. 一定是与com.sun:tools.jar有关的其他事情……通过我的POM,但是如果有人在使用JHipster之前经历过此事,请大声疾呼。 Thank you for the help! 感谢您的帮助!

There were 3 issues here: 这里有3个问题:

  1. My Eclipse configuration was pointing to a JRE rather than a JDK (which contained the right com.sun:tools jar). 我的Eclipse配置指向的是JRE,而不是JDK (其中包含正确的com.sun:tools jar)。 In order to make the correct updates, however, it wasn't as simple as updating my JAVA_HOME variable and moving on... See steps 1-5 below. 但是,为了进行正确的更新,它不像更新我的JAVA_HOME变量并继续操作那样简单。请参阅下面的步骤1-5。
  2. My application-dev.yml properties file was not pointing to a generated database. 我的application-dev.yml属性文件未指向生成的数据库。 Eclipse was simply having trouble generating the connection pool, and rather than throwing a descriptive error, would bomb out instead. Eclipse只是在生成连接池时遇到麻烦,并且不会抛出描述性错误,反而会炸掉。 See step 8 below. 请参阅下面的步骤8。
  3. My project was a spring-boot project and therefore wasn't able to be executed on the general Tomcat Server in Eclipse. 我的项目是一个春季启动项目 ,因此无法在Eclipse中的常规Tomcat服务器上执行。 See step 9 below. 请参阅下面的步骤9。

Summary of Resolution 决议摘要

  1. Change %JAVA_HOME% to JDK 将%JAVA_HOME%更改为JDK
  2. Update eclipse.ini with the following lines: 用以下几行更新eclipse.ini:
    • -vm -vm
    • C:\\Program Files\\Java\\jdk1.7.0_25\\bin\\ C:\\ Program Files \\ Java \\ jdk1.7.0_25 \\ bin \\
  3. Update Eclipse preferences : 'Window > Preferences > Java > Installed JREs' > delete and add new JDK 更新Eclipse首选项:“窗口>首选项> Java>已安装的JRE”>删除并添加新的JDK
  4. Update project properties : 'Project > Properties > Java Build Path' > delete old JRE and add new JDK 更新项目属性:“项目>属性> Java构建路径”>删除旧的JRE并添加新的JDK
  5. Close all open command prompts and active servers (that might be caching what %JAVA_HOME% was... I spent an hour before I realized this) 关闭所有打开的命令提示符和活动的服务器(可能正在缓存%JAVA_HOME%是...我花了一个小时才意识到这一点)
  6. mvn clean package mvn清洁包装
  7. Tell SureFire to be skipped during build in POM 告诉SureFire在POM中构建期间被跳过
  8. Make sure to update your application-dev.yml file to point to a real database (executing in Eclipse just shows that there was an exception of memory loss, but running mvn spring-boot:run will give you better error reporting). 确保将您的application-dev.yml文件更新为指向实际数据库(在Eclipse中执行只是显示内存丢失异常,但是运行mvn spring-boot:run将为您提供更好的错误报告)。
  9. If it is a spring-boot application, run it as a spring-boot application, not directly on the Tomcat Server in Eclipse. 如果它是spring-boot应用程序,则应将其作为spring-boot应用程序运行,而不是直接在Eclipse的Tomcat Server上运行。 I haven't yet researched why this is such a pain, but I'll come back to that later. 我还没有研究为什么会这么痛苦,但是我稍后再讲。 Please add detail in the comments if you know. 如果您知道,请在评论中添加详细信息。

< skip>true< /skip> ...minus the extra spaces <skip> true </ skip> ...减去多余的空格

The problem with running things in Eclipse first rather than Maven - the error logging is terribly misleading! 首先在Eclipse中而不是在Maven中运行事物的问题-错误日志记录极具误导性!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM