无法执行目标org.grails:grails-maven-plugin:2.4.4:maven-grails-app-war

时间:2015-09-22 14:22:03

标签: java spring maven grails

我使用 grails create-pom 将我的Grails应用转换为Maven项目

我希望创建一个战争并执行 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>

我在创建战争时遇到以下错误

[错误]无法在项目cds上执行目标org.grails:grails-maven-plugin:2.4.4:maven-grails-app-war(default-maven-grails-app-war):执行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退出时出错 - &gt; [帮助1] org.apache.maven.lifecycle.LifecycleExecutionException:无法在项目cds上执行目标org.grails:grails-maven-plugin:2.4.4:maven-grails-app-war(default-maven-grails-app-war):执行default-maven-grails-app-war of goal org.grails:grails-maven-plugin:2.4.4:maven-grails-app-war failed:error forking vm:     在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)     在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)     在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)

1 个答案:

答案 0 :(得分:2)

在花了好几个小时同样的问题之后,我找到了一个解决方案,我希望它也适合你,所以,首先我使用 grails 2.5.2 maven 3.1。 0 ,在我的情况下,错误告诉我没有足够的PermGen空间,由于内存泄漏,能够避免此问题的独特方法是为插件分配更多内存,如下所示,这是我的解决方案以及我如何配置该插件。

执行命令

mvn clean install -e

错误

[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...

<强>解决方案

   <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>

我是新来的,所以,这可能是我的第一个答案。 问候并祝你好运。