I am trying to deploy the first example (hello1) from the Java 7/8 EE tutorial* using Netbeans and I am running into problems. The project compiles without problems but when deploying it gives an error:
Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.4.2:redeploy (deploy) on project hello1: Execution deploy of goal org.codehaus.cargo:cargo-maven2-plugin:1.4.2:redeploy failed: Failed to create deployer with implementation class org.codehaus.cargo.container.glassfish.GlassFish4xInstalledLocalDeployer for the parameters (container [id = [glassfish4x]], deployer type [installed]). InvocationTargetException: The container configuration directory "/home/DeltaLima/glassfish4/glassfish/domains" does not exist. Please configure the container before attempting to perform any local deployment. Read more on: http://cargo.codehaus.org/Local+Configuration -> [Help 1]
Contrary to the tutorial I installed the GlassFish server in /opt/glassfish-v4 instead of /home/DeltaLima/glassfish4. In Netbeans I configured it that way, so I can start, stop and check the status of the server without any problems. The domains folder in the server configuration is set correctly.
It seems that the Maven installation bundled with Netbeans expects the server to be installed in the user's home directory nevertheless.
I am new to Java EE, Netbeans and Maven so I have no experience configuring Netbeans / Maven and neither the tutorial or the link provided in the error message are of much help.
How do you set up the project in Netbeans in such a way that it deploys in the right directory?
Netbeans version 7.3.1
Glassfish version 4.0
OS: Ubuntu
*Answer updated to account for Java 8 EE as well
DeltaLima's answer is the correct. But you can locally overload the property in your project. Consider that you have installed glassfish5 in the folder /opt. Then you can add this code into pom.xml of the project hello1 just before the last tag </project>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<container>
<containerId>glassfish4x</containerId>
<type>installed</type>
<home>/opt/glassfish5</home>
</container>
<configuration>
<type>existing</type>
<home>/opt/glassfish5/glassfish/domains</home>
</configuration>
</configuration>
</plugin>
</plugins>
</build>
After searching through various configuration files I finally found the solution to my problem.
The domains folder used by Maven / Cargo is defined in a pom.xml file that is in the grand-grandparent folder of the project directory.
In tut-install/examples/pom.xml you need to change the <glassfish.home>
property to reflect your glassfish installation directory.
In JAVA 8 EE a property called was introduced to serve the same purpose.
Settings defined in this pom.xml cascade down to all tutorial examples.
I resolved this problem adding those lines to my pom.xml
<profiles>
<profile>
<id>windows</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<properties>
<glassfish.home>C://Program Files//glassfish-4.1.1</glassfish.home>
</properties>
</profile>
</profiles>
I hope this help
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With