我正在尝试使用Netbeans从Java 7/8 EE tutorial *部署第一个示例(hello1),但遇到了问题。该项目编译没有问题,但是在部署时会出现错误:

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]

与本教程相反,我将GlassFish服务器安装在/opt/glassfish-v4中,而不是在/home/DeltaLima/glassfish4中。在Netbeans中,我以这种方式进行了配置,因此我可以启动,停止和检查服务器的状态,而不会出现任何问题。服务器配置中的domains文件夹设置正确。

不过,似乎与Netbeans捆绑在一起的Maven安装仍希望将服务器安装在用户的主目录中。

我是Java EE,Netbeans和Maven的新手,所以我没有配置Netbeans/Maven的经验,并且错误消息中提供的教程或链接都无济于事。

您如何以正确的目录中的部署方式在Netbeans中设置项目?

Netbeans版本7.3.1
Glassfish版本4.0
操作系统:Ubuntu

*更新的答案也考虑到了Java 8 EE

最佳答案

搜索了各种配置文件后,我终于找到了解决问题的方法。

Maven/Cargo使用的domains文件夹是在项目目录的grand-grandparent文件夹中的pom.xml文件中定义的。

在tut-install/examples/pom.xml中,您需要更改<glassfish.home>属性以反射(reflect)您的glassfish安装目录。

在JAVA 8 EE中,引入了一个属性以实现相同的目的。

在此pom.xml中定义的设置可以级联到所有教程示例。

10-02 04:21
查看更多