2

So I have a problem, I'm following the tutorial Working with Custom Content types in Alfresco but i get a maven problem when I try to install the program. It tells me there is a problem about the maven surefire plugin as shown here :

    C:\Users\admin\Desktop\tutorial_home\content-tutorial-repo>mvn install
Java HotSpot(TM) Client VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building content-tutorial-repo Repository AMP project 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https://artifacts.alfresco.com/nexus/content/groups/public/org/apache/maven/plugins/maven-deploy-plugin/maven-metadata.xml
Downloading: https://oss.sonatype.org/content/repositories/snapshots/org/apache/maven/plugins/maven-deploy-plugin/maven-metadata.xml
Downloading: https://artifacts.alfresco.com/nexus/content/groups/public-snapshots/org/apache/maven/plugins/maven-deploy-plugin/maven-metadata.xml
Downloading: http://oss.sonatype.org/content/groups/public/org/apache/maven/plugins/maven-deploy-plugin/maven-metadata.xml
[INFO]
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-sdk-requirements) @ content-tutorial-repo ---
[INFO]
[INFO] --- alfresco-maven-plugin:2.2.0:set-version (default-set-version) @ content-tutorial-repo ---
[INFO] Removed -SNAPSHOT suffix from version - 1.0
[INFO] Added timestamp to version - 1.0.1704260956
[INFO]
[INFO] --- build-helper-maven-plugin:1.10:add-test-resource (add-env-test-properties) @ content-tutorial-repo ---
[INFO]
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ content-tutorial-repo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\admin\Desktop\tutorial_home\content-tutorial-repo\src\main\resources
[INFO] Copying 17 resources to C:\Users\admin\Desktop\tutorial_home\content-tutorial-repo\target/amp
[INFO]
[INFO] --- alfresco-maven-plugin:2.2.0:refresh (refresh-webscripts-repo-and-share) @ content-tutorial-repo ---
[WARNING] Connection failed to localhost:8080, null webapp refresh aborted
[INFO]
[INFO] --- maven-compiler-plugin:3.5:compile (default-compile) @ content-tutorial-repo ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ content-tutorial-repo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-resources-plugin:2.7:copy-resources (add-module-properties-to-test-classpath) @ content-tutorial-repo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource to alfresco/module/content-tutorial-repo
[INFO]
[INFO] --- maven-resources-plugin:2.7:copy-resources (add-module-config-to-test-classpath) @ content-tutorial-repo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 12 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5:testCompile (default-testCompile) @ content-tutorial-repo ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.19.1:test (default-test) @ content-tutorial-repo ---

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Error occurred during initialization of VM
Could not reserve enough space for 1560576KB object heap
Java HotSpot(TM) Client VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.226 s
[INFO] Finished at: 2017-04-26T09:56:10+02:00
[INFO] Final Memory: 18M/44M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project content-tutorial-repo: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was cmd.exe /X /C ""C:\Program Files (x86)\Java\jdk1.8.0_121\jre\bin\java" -Xms256m -Xmx1524m -XX:MaxPermSize=256m -Duser.language=en -jar C:\Users\admin\Desktop\tutorial_home\content-tutorial-repo\target\surefire\surefirebooter6817806541714880563.jar C:\Users\admin\Desktop\tutorial_home\content-tutorial-repo\target\surefire\surefire2049933145142894733tmp C:\Users\admin\Desktop\tutorial_home\content-tutorial-repo\target\surefire\surefire_03570301801919192406tmp"
[ERROR] -> [Help 1]
[ERROR]
[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/PluginExecutionException

Problem is i have no such directory in my project as you can see in the . So where do I find it or generate it with maven ?

Tahnk you for your help !

Jack
  • 695
  • 10
  • 29
  • `Could not reserve enough space for 1560576KB object heap` is what you should retain from this log. I can't look at your screenshot (*.imgur.com is blocked for me) but if you're talking about the `target\surefire\` dir, it must have been removed after failure – Aaron Apr 26 '17 at 08:37
  • Yes I'm talking about the "target\surefire" directory. – Jack Apr 26 '17 at 08:46
  • Since the build failed, the `target` directory must have been cleaned up so that you won't think you've got an actual package ready. Anyway you have to fix the heap allocation failure (or you could skip the surefire tests to avoid the problem) – Aaron Apr 26 '17 at 08:47
  • Yes I'm talking about the "target\surefire" directory. So how do I allow more space to this ? My environment variable for MAVEN_OPTS is -Xmx1024M I thought it was due to this at first – Jack Apr 26 '17 at 08:51
  • I've updated my answer with a link to the relevant surefire configuration (the anchor is badly handled by the site, the setting I refer to is the jvm one, where you should be able to specify a -Xmx) – Aaron Apr 26 '17 at 08:56
  • Actually I'm wrong ! the JVM settings will specify a JDK/JRE location. Use the `argLine` parameter where you can specify `-Xmx 512m` for example – Aaron Apr 26 '17 at 09:00
  • -Xms512m -Xmx1524m -XX:MaxPermSize=512m -Duser.language=en is what I should add for example ? But where ? If I could solve the problem instead of skipping it it would be better I think since I'm discovering everything, the less errors I have the better aha P.S : thank you for your help – Jack Apr 26 '17 at 09:08
  • Yes that's be best indeed. Concerning your current arguments, I think it might fail too since `1524m` is the size you're currently failing to allocate. I've found an example [here](http://maven.40175.n5.nabble.com/Specifying-Xmx-in-surefire-plugin-td57529.html), and I would recommend just changing the `-Xmx` at first in order to do the least amount of modifications ; if you encounter OutOfMemoryError you'll have to increase it in small steps. – Aaron Apr 26 '17 at 09:14
  • I've added a link to a SU question about modifying available swap space to my answer too, it might be an easier fix – Aaron Apr 26 '17 at 09:17
  • In which file should I ad this ? – Jack Apr 26 '17 at 09:28
  • In your `pom.xml`. Check out [maven's guide to configuring plugins](https://maven.apache.org/guides/mini/guide-configuring-plugins.html), where the "Configuring Build Plugins / using the tag" probably is the relevant part. Good luck, getting into maven surely isn't easy – Aaron Apr 26 '17 at 09:32
  • Merci beaucoup ! – Jack Apr 26 '17 at 09:33
  • Je t'en prie ;) – Aaron Apr 26 '17 at 09:34

3 Answers3

3
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Error occurred during initialization of VM
Could not reserve enough space for 1560576KB object heap

This is the root of your problem : while trying to do tests, the surefire plugin tries to instantiate a JVM but fails because it can't allocate enough memory. The lack of the target\surefire directory is just a result of that failure, the target directory being cleaned up after failure.

You should try, in order of preference :

  • to have more memory available for the JVM which will run the tests. That could be solved by increasing your available swap memory for example

  • to limit the memory used by the test JVM. Take a look at the surefire plugin configuration, you can set JVM parameters

  • to skip the tests alltogether : use mvn install -DskipTests ; of course the execution isn't the same anymore

Aaron
  • 24,009
  • 2
  • 33
  • 57
2

Ok, so I solved my problem adding these lines to my pom.xml

 <build>
    <plugins>
        <plugin> 
            <groupId>org.apache.maven.plugins</groupId> 
            <artifactId>maven-surefire-plugin</artifactId> 
            <configuration> 
                <argLine>-Xmx512m</argLine> 
                <forkMode>pertest</forkMode> 
                <childDelegation>true</childDelegation> 
                <testFailureIgnore>true</testFailureIgnore> 
            </configuration>
        </plugin>
    </plugins>
</build>

Merci encore @Aaron

EDIT : if you encounter those memory types of problem you may need to install JDK in x64 if you didn't. That should resolve more than just this issue.

Jack
  • 695
  • 10
  • 29
0

The tutorial suggests that you disable the test run. Run the following command instead: mvn install -DskipTests=true

jacques
  • 55
  • 1
  • 6