Question

I am building up a baseline JHipster project with no bells and whistles involved (no clustering, etc.). 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. 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...

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

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. My project is directly configured to use JRE 1.7. My POM is below. Another thought is that it is directly related to the original NPM install from Hipster (after POM):

<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

Looking at what is being responded by NPM at initial JHipster generation, I am actually seeing errors in those logs as well, noted below. 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.

Back to 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. Thank you for the help!

Était-ce utile?

La solution

There were 3 issues here:

  1. My Eclipse configuration was pointing to a JRE rather than a JDK (which contained the right 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.
  2. My application-dev.yml properties file was not pointing to a generated database. Eclipse was simply having trouble generating the connection pool, and rather than throwing a descriptive error, would bomb out instead. See step 8 below.
  3. My project was a spring-boot project and therefore wasn't able to be executed on the general Tomcat Server in Eclipse. See step 9 below.

Summary of Resolution

  1. Change %JAVA_HOME% to JDK
  2. Update eclipse.ini with the following lines:
    • -vm
    • C:\Program Files\Java\jdk1.7.0_25\bin\
  3. Update Eclipse preferences : 'Window > Preferences > Java > Installed JREs' > delete and add new JDK
  4. Update project properties : 'Project > Properties > Java Build Path' > delete old JRE and add new 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)
  6. mvn clean package
  7. Tell SureFire to be skipped during build in 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).
  9. If it is a spring-boot application, run it as a spring-boot application, not directly on the Tomcat Server in Eclipse. 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

The problem with running things in Eclipse first rather than Maven - the error logging is terribly misleading!

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top