jenkins Maven编译问题:系统资源不足

9w11ddsr  于 2022-11-01  发布在  Jenkins
关注(0)|答案(1)|浏览(549)

我知道有很多人和我遇到了同样的问题。我在使用Eclipse的Maven编译器插件编译它时遇到了困难。我几乎尝试了其他人建议的所有故障排除方法。任何帮助都是很好的!

ERROR DETAILS:
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ WebScraper ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 12 source files to E:\Projects\Workspace\Repos\git\automateon2.0\WebScraper\target\classes

系统资源不足.有关详细信息,请参阅以下堆栈跟踪.

java.lang.StackOverflowError
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:418)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:460)
at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:2062)
at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1565)

注:以上4行重复20次以上

[ERROR] An unknown compilation problem occurred
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project WebScraper: Compilation failure
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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/MojoFailureException

已对以下问题进行故障诊断:

1.尝试增加pom.xml中maven插件配置节点的内存

<argLine> -Xmx512m -XX:MaxPermSize=256m</argLine> 
MAVEN_OPTS = Xmx512m -XX:MaxPermSize=128m

2.尝试为MAVEN_OPTS环境变量设置和增加内存

-Xms1024m -Xmx1024m -XX:MaxPermSize=256m

系统信息:

Windows 7 - 64位|编译插件版本:3.1|Kepler64

**我的项目的性质:**Maven,TestNG项目,有几个java类。我使用casperJs框架从网页中抓取数据,并将它们保存在电子表格中。我在java类中使用js代码作为字符串,因为我需要传递Testng参数。我热衷于使用maven编译器,因为我必须在Jenkins中托管它并执行maven命令。如果我尝试使用Java编译main方法,我可以执行,并且我可以使用testng.xml执行我的项目。例如:

@Test
public static String diceJS(String keyword, String Filepath)
{
    String filepath=Filepath.replace("\\", "/");
    String str="var casper=require('casper').create();"
    +"\n"+"var fs = require('fs');"
    +"\n"+"var key='"+keyword+"';"
    +"\n"+"var x=require('casper').selectXPath;"
::::::::::: THIS IS SAMPLE. THERE IS HUGE STRING THAT I HAVE TO USE :::::::::::     
}

pom.xml:

<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>WebScraper</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
    <sourceDirectory>src/test/java</sourceDirectory>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration> 
                <source>1.7</source> 
                <target>1.7</target>
                <extraJvmArgs>-Xms768m -Xmx768m</extraJvmArgs> 
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.14</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>testng.xml</suiteXmlFile>
                </suiteXmlFiles> 
                <systemPropertyVariables>
                    <buildnumber>${build.number}</buildnumber>
                </systemPropertyVariables>
                <properties>

                </properties>
            </configuration> 
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>net.sourceforge.jexcelapi</groupId>
        <artifactId>jxl</artifactId>
        <version>2.6</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.7</version>
    </dependency>
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>10.0.1</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-lgpl</artifactId>
        <version>1.4.2</version>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.3</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-core-asl</artifactId>
        <version>1.0.0</version>
    </dependency>
</dependencies>
ecbunoof

ecbunoof1#

这通常发生在编译阶段。
在我的例子中,我这样解决这类问题:

env MAVEN_OPTS="-Xmx2g -Xss10m" mvn compiler:compile

相关问题