Reputation: 3898
I converted my Grails app to Maven project using grails create-pom
I wish create a war and execute mvn clean compile install
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">
<parent>
<artifactId>services</artifactId>
<groupId>com.bankbazaar</groupId>
<version>yt-2161</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.bankbazaar</groupId>
<artifactId>cds</artifactId>
<packaging>grails-app</packaging>
<name>cds</name>
<description>cds</description>
<properties>
<grails.version>2.4.4</grails.version>
<h2.version>1.3.170</h2.version>
</properties>
<dependencies>
<dependency>
<groupId>com.bankbazaar</groupId>
<artifactId>core</artifactId>
<version>yt-2161</version>
</dependency>
<dependency>
<groupId>org.grails</groupId>
<artifactId>grails-dependencies</artifactId>
<version>${grails.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.grails</groupId>
<artifactId>grails-test</artifactId>
<version>${grails.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.grails</groupId>
<artifactId>grails-plugin-testing</artifactId>
<version>${grails.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>0.7-groovy-2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.grails</groupId>
<artifactId>grails-datastore-test-support</artifactId>
<version>1.0.2-grails-2.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>scaffolding</artifactId>
<version>2.1.2</version>
<scope>compile</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>cache</artifactId>
<version>1.1.8</version>
<scope>compile</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>asset-pipeline</artifactId>
<version>1.9.9</version>
<scope>compile</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>hibernate4</artifactId>
<version>4.3.6.1</version>
<scope>runtime</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>database-migration</artifactId>
<version>1.4.0</version>
<scope>runtime</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>jquery</artifactId>
<version>1.11.1</version>
<scope>runtime</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>tomcat</artifactId>
<version>7.0.55</version>
<scope>provided</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>webxml</artifactId>
<version>1.4.1</version>
<type>zip</type>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<pluginManagement/>
<finalName>cds</finalName>
<plugins>
<!-- Disables the Maven surefire plugin for Grails applications, as we have our own test runner -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>surefire-it</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4</version>
<configuration>
<filesets>
<fileset>
<directory>plugins</directory>
<includes>
<include>**/*</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.grails</groupId>
<artifactId>grails-maven-plugin</artifactId>
<version>2.4.4</version>
<configuration>
<fork>true</fork>
<grailsVersion>${grails.version}</grailsVersion>
</configuration>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>grails</id>
<name>grails</name>
<url>https://repo.grails.org/grails/core</url>
</repository>
<repository>
<id>grails-plugins</id>
<name>grails-plugins</name>
<url>https://repo.grails.org/grails/plugins</url>
</repository>
</repositories>
<profiles>
<profile>
<id>tools</id>
<activation>
<property>
<name>java.vendor</name>
<value>Sun Microsystems Inc.</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>${java.version}</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
I get the below error during creation of war
[ERROR] Failed to execute goal org.grails:grails-maven-plugin:2.4.4:maven-grails-app-war (default-maven-grails-app-war) on project cds: Execution default-maven-grails-app-war of goal org.grails:grails-maven-plugin:2.4.4:maven-grails-app-war failed: Error forking vm: Forked Grails VM exited with error -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.grails:grails-maven-plugin:2.4.4:maven-grails-app-war (default-maven-grails-app-war) on project cds: Execution default-maven-grails-app-war of goal org.grails:grails-maven-plugin:2.4.4:maven-grails-app-war failed: Error forking vm: at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
Upvotes: 0
Views: 3035
Reputation: 62
After spending hours with the same issue, i have found a solution, i hope it works for you too, so, first i'm using grails 2.5.2 and maven 3.1.0, in my case the error show me that there were not enough PermGen space, due to a memory leak, the unique way to be able to avoid this issue was assigning more memory to the plugin, as you can see below, it was my solution and how i configured that plugin.
command executed:
mvn clean install -e
error:
[ERROR] Failed to execute goal org.grails:grails-maven-plugin:2.4.6:maven-grails-app-war (default-maven-grails-app-war) on project myapp: Execution default-maven-grails-app-war of g
oal org.grails:grails-maven-plugin:2.4.6:maven-grails-app-war failed: java.lang.reflect.InvocationTargetException: PermGen space -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.grails:grails-maven-plugin:2.4.6:maven-grails-app-war (default-maven-grails-app-war) on project my
app: Execution default-maven-grails-app-war of goal org.grails:grails-maven-plugin:2.4.6:maven-grails-app-war failed: java.lang.reflect.InvocationTargetException
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:318)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:414)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:357)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-maven-grails-app-war of goal org.grails:grails-maven-plugin:2.4.6:maven-grails-app-war failed: java.la
ng.reflect.InvocationTargetException
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:115)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.grails.launcher.GrailsLauncher.launch(GrailsLauncher.java:150)
at org.grails.maven.plugin.tools.DefaultGrailsRuntime.run(DefaultGrailsRuntime.java:18)
at org.grails.maven.plugin.AbstractGrailsMojo.runGrails(AbstractGrailsMojo.java:372)
at org.grails.maven.plugin.MvnWarMojo.execute(MvnWarMojo.java:58)
at org.grails.maven.plugin.MvnGrailsAppWarMojo.execute(MvnGrailsAppWarMojo.java:53)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
... 20 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.grails.launcher.GrailsLauncher.launch(GrailsLauncher.java:144)
... 25 more
Caused by: java.lang.OutOfMemoryError: PermGen space
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:100)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
at org.codehaus.groovy.runtime.callsite.BooleanReturningMethodInvoker.invoke(BooleanReturningMethodInvoker.java:51)
at org.codehaus.groovy.runtime.callsite.BooleanClosureWrapper.call(BooleanClosureWrapper.java:53)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.findAll(DefaultGroovyMethods.java:4281)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.findAll(DefaultGroovyMethods.java:4256)
at grails.util.PluginBuildSettings.resolvePluginResourcesAndAdd(PluginBuildSettings.groovy:861)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:182)
at grails.util.PluginBuildSettings.getPluginSourceDirectories(PluginBuildSettings.groovy:418)
at grails.util.PluginBuildSettings.getPluginSourceDirectories(PluginBuildSettings.groovy:434)
at grails.util.PluginBuildSettings.addPluginScopeInfoForDirAndInfo(PluginBuildSettings.groovy:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:182)
at grails.util.PluginBuildSettings.registerPluginZipWithScope(PluginBuildSettings.groovy:170)
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
C:\workspace\Grails-Module\Maven-Integration\myapp>mvn clean install -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
Solution:
<plugin>
<groupId>org.grails</groupId>
<artifactId>grails-maven-plugin</artifactId>
<version>2.4.6</version>
<configuration>
<grailsVersion>${grails.version}</grailsVersion>
<fork>true</fork>
<meminitial>128m</meminitial>
<maxmem>512m</maxmem>
<source>1.6</source>
<target>1.6</target>
<!-- prevent PermGen space out of memory exception -->
<!-- <argLine>-Xmx512m -XX:MaxPermSize=512m</argLine> -->
</configuration>
<extensions>true</extensions>
</plugin>
I'm new here, so, this it could be my first answer. Regards and good luck.
Upvotes: 2