0

I'm trying to run unit and intergartion tests for jee wildfly application. During tests execution i'm getting stack overflow. I tried to increase memory but wihout success. In my opinion it looks like oom during package creation but i'm not sure.

Can you help? I want also generate jacoco coverage.

I'm using wildfly 10.

Running ......AddRemoveProjectTestCase
Exception in thread "management-client-thread 1-2" java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:3236)
    at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:118)
    at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
    at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153)
    at org.jboss.as.protocol.StreamUtils.copyStream(StreamUtils.java:52)
    at org.jboss.as.controller.client.impl.InputStreamEntry$InMemoryEntry.initialize(InputStreamEntry.java:76)
    at org.jboss.as.controller.client.impl.AbstractModelControllerClient$ReadAttachmentInputStreamRequestHandler$1.execute(AbstractModelControllerClient.java:193)
    at org.jboss.as.protocol.mgmt.AbstractMessageHandler$2$1.doExecute(AbstractMessageHandler.java:283)
    at org.jboss.as.protocol.mgmt.AbstractMessageHandler$AsyncTaskRunner.run(AbstractMessageHandler.java:504)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at org.jboss.threads.JBossThread.run(JBossThread.java:122)

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>
    ..............
    <packaging>war</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <sonar.language>java</sonar.language>
        <sonar.login>admin</sonar.login>
        <sonar.password>admin</sonar.password>
        <sonar.host.url>http://sonar:9000/</sonar.host.url>
        <version.org.jboss.arquillian.graphene>2.1.0.Alpha3</version.org.jboss.arquillian.graphene>


        <version.jacoco>0.7.5.201505241946</version.jacoco>
        <version.arquillian_jacoco>1.0.0.Alpha8</version.arquillian_jacoco>
    </properties>

    <dependencies>
        <!-- http://mvnrepository.com/artifact/dom4j/dom4j -->
        <dependency>
            <groupId>dom4j</groupId>
            <artifactId>dom4j</artifactId>
            <version>1.6.1</version>
            <scope>provided</scope>
        </dependency>


        <!-- for e2e tests only: start -->
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.0.4</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.10.19</version>
        </dependency>

        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>xml-apis</groupId>
            <artifactId>xml-apis</artifactId>
            <version>1.4.01</version>
        </dependency>


        <!-- for e2e tests only: stop -->

        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.9.1</version>
        </dependency>

        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.14</version>
        </dependency>

        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.14</version>
        </dependency>


        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
            <version>3.1.4.GA</version>
        </dependency>

        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>6.0</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>3.6.8.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-commons-annotations</artifactId>
            <version>3.2.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.jbossts</groupId>
            <artifactId>jbossjta</artifactId>
            <version>4.16.4.Final</version>
        </dependency>

        <!-- unit tests -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- GUI tests -->
        <dependency>
            <groupId>org.jacoco</groupId>
            <artifactId>org.jacoco.core</artifactId>
            <version>${version.jacoco}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.extension</groupId>
            <artifactId>arquillian-jacoco</artifactId>
            <version>${version.arquillian_jacoco}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-arquillian-container-remote</artifactId>
            <version>8.2.1.Final</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.arquillian.graphene</groupId>
            <artifactId>graphene-webdriver</artifactId>
            <version>${version.org.jboss.arquillian.graphene}</version>
            <type>pom</type>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.arquillian.extension</groupId>
            <artifactId>arquillian-drone-webdriver-depchain</artifactId>
            <type>pom</type>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.shrinkwrap.resolver</groupId>
            <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.seleniumhq.webdriver</groupId>
            <artifactId>webdriver-common</artifactId>
            <version>0.9.7376</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.weld</groupId>
            <artifactId>weld-core</artifactId>
            <version>2.3.5.Final</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.5</version>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.jboss.arquillian</groupId>
                <artifactId>arquillian-bom</artifactId>
                <version>1.1.11.Final</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>

            <dependency>
                <groupId>org.jboss.arquillian.extension</groupId>
                <artifactId>arquillian-drone-bom</artifactId>
                <version>1.3.1.Final</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>

            <dependency>
                <groupId>org.jboss.arquillian.selenium</groupId>
                <artifactId>selenium-bom</artifactId>
                <version>2.53.0</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>


        </dependencies>
    </dependencyManagement>

    <build>
        <finalName>${project.artifactId}</finalName>

        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
            </testResource>
        </testResources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.15</version>
                <configuration>
                    <argLine>-Xms128m -Xmx4G -XX:MaxPermSize=2G</argLine>
                    <!-- Sets the VM argument line used when unit tests are run. -->
                    <argLine>${surefireArgLine}</argLine>
                    <!-- Skips unit tests if the value of skip.unit.tests property is true -->
                    <skipTests>${skip.unit.tests}</skipTests>
                    <!-- Excludes integration tests when unit tests are run. -->
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.15</version>
                <executions>
                    <!-- Ensures that both integration-test and verify goals of the Failsafe 
                        Maven plugin are executed. -->
                    <execution>
                        <id>integration-tests</id>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                        <configuration>
                            <!-- Sets the VM argument line used when integration tests are run. -->
                            <argLine>${failsafeArgLine}</argLine>
                            <!-- Skips integration tests if the value of skip.integration.tests 
                                property is true -->
                            <skipTests>${skip.integration.tests}</skipTests>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>sonar-maven-plugin</artifactId>
                <version>2.7.1</version>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${version.jacoco}</version>

                <executions>
                    <!-- Prepares the property pointing to the JaCoCo runtime agent which 
                        is passed as VM argument when Maven the Surefire plugin is executed. -->
                    <execution>
                        <id>pre-unit-test</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <!-- Sets the path to the file which contains the execution data. -->
                            <destFile>${project.build.directory}/jacoco.exec</destFile>
                            <!-- Sets the name of the property containing the settings for JaCoCo 
                                runtime agent. -->
                            <propertyName>surefireArgLine</propertyName>
                        </configuration>
                    </execution>
                    <!-- Ensures that the code coverage report for unit tests is created 
                        after unit tests have been run. -->
                    <execution>
                        <id>post-unit-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <!-- Sets the path to the file which contains the execution data. -->
                            <dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
                            <!-- Sets the output directory for the code coverage report. -->
                            <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
                        </configuration>
                    </execution>

                    <execution>
                        <id>pre-integration-test</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <!-- Sets the path to the file which contains the execution data. -->
                            <destFile>${project.build.directory}/jacoco-it.exec</destFile>
                            <!-- Sets the name of the property containing the settings for JaCoCo 
                                runtime agent. -->
                            <propertyName>failsafeArgLine</propertyName>
                        </configuration>
                    </execution>
                    <!-- Ensures that the code coverage report for integration tests after 
                        integration tests have been run. -->
                    <execution>
                        <id>post-integration-test</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <!-- Sets the path to the file which contains the execution data. -->
                            <dataFile>${project.build.directory}/coverage-reports/jacoco-it.exec</dataFile>
                            <!-- Sets the output directory for the code coverage report. -->
                            <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
                        </configuration>
                    </execution>

                </executions>

            </plugin>

            <!-- WildFly plugin to deploy the application -->
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <version>1.0.2.Final</version>
                <configuration>
                    <filename>${project.build.finalName}.war</filename>
                    <hostname>wildfly</hostname>
                    <port>9990</port>
                    <username>user</username>
                    <password>password</password>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <archive>
                        <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <!-- enforce Java 8 -->
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

        </plugins>
    </build>
</project>

arquillian.xml

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

    <defaultProtocol type="Servlet 3.0" />

    <extension qualifier="webdriver">
        <property name="browser">chrome</property>
    </extension>

    <container qualifier="widlfly-remote" default="true">
        <configuration>
            <property name="javaVmArguments">-Xms512m -Xmx4G</property>
            <property name="managementAddress">wildfly</property>
            <property name="managementPort">9990</property>
            <property name="username">user</property>
            <property name="password">password</property>
        </configuration>
        <protocol type="Servlet 3.0">
            <property name="host">widfly</property>
            <property name="port">8080</property>
        </protocol>
    </container>

</arquillian>

PS: On jenkins slave is see that used memeory is only 1G

test proces

system monitor performance tab

Still problem:

Hi, i see that increasing memory don't fix the problem. Insufficient memory was not the reason of the problems. Now i need 6GB RAM and i have 47% of code coverage. So if memory will increase lineary i will need 12GB of free RAM to test my 40MB(with libraries and pictures) app. I think that there is something wrong with that. It looks like memory leak.

Is it normal to have such big memory consumption in arquillian + jacoco configuration?

skoczo
  • 75
  • 1
  • 12
  • Possible duplicate of [Maven throws "java.lang.OutOfMemoryError"](http://stackoverflow.com/questions/1920059/maven-throws-java-lang-outofmemoryerror) – Radouane ROUFID Jul 12 '16 at 08:08
  • I set -DMAVEN_OPTS=-Xmx2G and still get OutOfMemory. – skoczo Jul 12 '16 at 08:39
  • Try to set `MAVEN_OPTS="-XX:MaxPermSize=2G"` before lunching your command – Radouane ROUFID Jul 12 '16 at 08:44
  • I called export MAVEN_OPTS="-XX:MaxPermSize=2G" and then mvn clean test sonar:sonar -D-DMAVEN_OPTS=-Xmx2G but still got OOM. I see that process is using only 1G of memeory. Screens attached. – skoczo Jul 12 '16 at 09:07
  • Try with a small "g" => `-DMAVEN_OPTS="-Xmx2g"` and if it doesn't work try then to increase Java heap size in JAVA_OPTS rather than MAVEN_OPTS => `JAVA_OPTS="-Xms1g -Xmx2g"` – Radouane ROUFID Jul 12 '16 at 09:13
  • Sitll the same situation. But when i removed maven-surefire-plugin, maven-failsafe-plugin and jacoco-maven-plugin from build then OOM not occured. So it looks like problem with memeory and configuration. I'm fighting with it form 3 days :(. Max memeory consuption by maven process was 1150MB – skoczo Jul 12 '16 at 10:04
  • When i run tests from eclipse OOM don't occure. I see that from eclipse consumes about 2.3GB. It looks like set memory for maven dont work at all. – skoczo Jul 12 '16 at 12:02
  • Check if you don't override the `MAVEN_OPTS` or `JAVA_OPTS` later on your script. – Radouane ROUFID Jul 12 '16 at 12:03
  • I have clue. I run tests on two computers one with 8GB or ram second 4GB. Problem with OOM occure only on second. RAM is not fully consumed by mvn process. Still about 1.5GB free memory when OOM occure. I will try to increase RAM(this is virtual machine). Mabye windows 8.1 have some limitations? – skoczo Jul 12 '16 at 12:30
  • How do you start your wildfly instance? Since you are using remote adapter `javaVmArguments` in `arquillian.xml` are not really used. – bartosz.majsak Jul 13 '16 at 06:27
  • Increasing RAM from 4 GB to 8GB solved the problem. I don't uderstand why because when i had 4GB 1.5GB was free when OOM occured. – skoczo Jul 13 '16 at 08:07
  • Wildfly is started remotly. I'm using widlfly-remote container. – skoczo Jul 13 '16 at 08:22

0 Answers0