【问题标题】:Configuring GlassFish 4 domain directory in Netbeans / Maven / Cargo plugin在 Netbeans / Maven / Cargo 插件中配置 GlassFish 4 域目录
【发布时间】:2013-08-15 00:34:15
【问题描述】:

我正在尝试使用 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 中我是这样配置的,所以我可以毫无问题地启动、停止和检查服务器的状态。服务器配置中的域文件夹设置正确。

似乎与 Netbeans 捆绑的 Maven 安装希望服务器安装在用户的主目录中。

我是 Java EE、Netbeans 和 Maven 的新手,因此我没有配置 Netbeans / Maven 的经验,并且错误消息中提供的教程或链接都没有太大帮助。

如何在 Netbeans 中设置项目,使其部署在正确的目录中?

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

*已更新答案以考虑 Java 8 EE

【问题讨论】:

    标签: maven jakarta-ee java-ee-7 maven-cargo java-ee-8


    【解决方案1】:

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

    Maven / Cargo 使用的域文件夹在项目目录的祖父文件夹中的 pom.xml 文件中定义。

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

    在 JAVA 8 EE 中引入了一个名为的属性来实现相同的目的。

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

    【讨论】:

    • 谢谢。在 Java EE 8 教程示例中,它现在是 <glassfish.home.prefix>
    • @JL_SO 谢谢你让我知道。我已经用你的信息更新了答案。
    【解决方案2】:

    我解决了这个问题,将这些行添加到我的 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>   
    

    希望对你有帮助

    【讨论】:

      【解决方案3】:

      DeltaLima 的答案是正确的。 但是您可以在项目中本地重载该属性。 假设您已经在文件夹 /opt 中安装了 glassfish5。 然后你可以将此代码添加到项目 hello1 的 pom.xml 中,就在最后一个标签

      之前
      <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>
      

      【讨论】:

        猜你喜欢
        • 2011-03-09
        • 1970-01-01
        • 2011-07-06
        • 1970-01-01
        • 1970-01-01
        • 2011-04-17
        • 2016-11-17
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多