不断出现的java.lang.OutOfMemoryError: PermGen空间问题Arquillian + Wildfly 8.1

4

你好,我开始了一个新项目。其中我想做的第一件事就是设置并运行Arquillian。 我已经写了一些控制器和JSF表单。

加载依赖项的过程

final File[] files = Maven.resolver().loadPomFromFile("pom.xml").importRuntimeAndTestDependencies().resolve()
                .withTransitivity().asFile();
LOG.info(files.toString());
final WebArchive archive = ShrinkWrap.create(WebArchive.class, "main-webapp-arq.war"); etc...

运行

mvn -PprofileName package

一切似乎顺利,我看到它开始启动WildFly,然后我看到它部署应用程序,启动Bean执行,但是随后出现了以下错误:

....
[0m[0m20:37:30,025 INFO  [org.apache.shiro.web.env.EnvironmentLoader] (MSC service thread 1-6) Shiro environment initialized in 123 ms.
[0mINFO  [javax.enterprise.resource.webcontainer.jsf.config] Initializing Mojarra 2.2.6-jbossorg-4 20140501-1134 for context '/hc'
WARN  [org.jboss.modules] Failed to define class javax.faces.FactoryFinder in Module "javax.faces.api:main" from local module loader @732e8099 (finder: local module finder @71fcf7e2 (roots: /Users/jgreenaw/dev/apps/wildfly/wildfly-8.1.0.Final-ARQ/modules,/Users/jgreenaw/dev/apps/wildfly/wildfly-8.1.0.Final-ARQ/modules/system/layers/base)): java.lang.OutOfMemoryError: PermGen space

WARN  [org.jboss.modules] Failed to define class com.sun.faces.application.ApplicationAssociate in Module "com.sun.jsf-impl:main" from local module loader @732e8099 (finder: local module finder @71fcf7e2 (roots: /Users/jgreenaw/dev/apps/wildfly/wildfly-8.1.0.Final-ARQ/modules,/Users/jgreenaw/dev/apps/wildfly/wildfly-8.1.0.Final-ARQ/modules/system/layers/base)): java.lang.OutOfMemoryError: PermGen space...

接着出现了其他服务因同样的原因无法加载。

我已经尝试了一些显而易见的方法,例如将maven和wildfly中的permgen提高到512mb,然后再提高到1024mb。但似乎有些根本性的问题。我可以在不做任何调整的情况下运行整个应用程序。

Arquillian.xml

<?xml version="1.0" encoding="UTF-8"?>
<arquillian xmlns="http://jboss.org/schema/arquillian"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

    <container qualifier="wildfly" default="true">
        <configuration>
            <!-- Supported property names: [managementPort, username, managementAddress, 
                bundlePath, managementProtocol, cleanServerBaseDir, jbossHome, password, 
                modulePath] -->
            <property name="jbossHome">/dev/apps/wildfly/wildfly-8.1.0.Final-ARQ/</property>
            <property name="modulePath">/dev/apps/wildfly/wildfly-8.1.0.Final-ARQ/modules</property>
            <property name="javaVmArguments">-Xms64m -Xmx1024m -XX:MaxPermSize=1024m -Dorg.jboss.resolver.warning=true</property>
        </configuration>
    </container>
</arquillian> 

相关(我认为)的pom依赖关系:

<dependency>
    <groupId>org.jboss.arquillian</groupId>
    <artifactId>arquillian-bom</artifactId>
    <version>1.1.5.Final</version>
</dependency>
<dependency>
    <groupId>org.jboss.arquillian.junit</groupId>
    <artifactId>arquillian-junit-container</artifactId>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.jboss.shrinkwrap.resolver</groupId>
    <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
    <scope>test</scope>
</dependency>
<profiles>
    <profile>
        <!-- Remote local Profile - Arquillian will deploy the test artifact to 
                a local server, test the artifact and undeploy -->
        <id>arq-wildfly-local</id>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>
        <properties>
            <skipTests>false</skipTests>
        </properties>
        <dependencies>
            <dependency>
                <groupId>org.wildfly</groupId>
                <artifactId>wildfly-arquillian-container-embedded</artifactId>
                <version>8.1.0.Final</version>
                <scope>test</scope>
            </dependency>
        </dependencies>

过去的经验表明我可能缺少一些基本知识,而PermGen耗尽是我做错了其他事情的症状。我尝试了各种Maven解析器中的.import...但都无济于事。在命令行和eclipse中都有同样的问题。
Java版本“1.7.0_60”,Apache Maven 3.2.1,wildfly 8.1,OS X Latest。
问题:有任何想法下一步该怎么做吗?提前感谢您。

刚遇到了同样的问题。如果我有任何进展,我会告诉你的。 - rtcarlson
1个回答

0
如果您正在使用Linux,则可以在.bashrc文件中添加以下命令:
export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=256m"
然后重置终端。
或者,您可以将这些值设置为环境变量。
另外,您还可以通过以下命令将这些值设置为Maven命令行参数:
-DXmx512m -DXX:MaxPermSize=512m

1
谢谢,我可以更改这些值并且我知道它们,但似乎没有关系。我可以在Wildfly中运行整个应用程序,只使用1/4的内存而没有任何问题。 - Pompey Magnus

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接