我正在尝试在本地PC上部署Netbeans/Glassfish项目。目前正在生产中

该项目似乎基于在此URL上找到的文档而被构造为企业应用程序:

https://netbeans.org/kb/docs/javaee/maven-entapp.html#intro

该项目具有以下5个模块:

WI-EAR
WI-EJB
WI-Enterprise
WI-ENT-web
WE-Web

根据上面引用的教程,用于从Netbeans运行和部署的项目是“-EAR”项目。

当我右键单击WI-EAR项目节点并选择Build with Dependencies时,按照本教程,我得到以下结果:
Reactor Summary:

WI-EJB ............................................ SUCCESS [0.723s]
WI-Enterprise ..................................... SUCCESS [0.004s]
Wi-LIB ............................................ SUCCESS [0.288s]
WI-ENT-web ........................................ SUCCESS [3.012s]
WI-EAR ............................................ SUCCESS [1.520s]
------------------------------------------------------------------------
BUILD SUCCESS

我可以在“目标”目录中的名称“WI-EAR”下看到创建的.ear文件。

到现在为止还挺好。接下来,再次按照本教程,我在“项目”窗口中右键单击EAR项目节点,然后选择“运行”。

但是,此时,GlassFish控制台显示以下错误:
SEVERE: Exception while deploying the app
java.lang.IllegalArgumentException: Expected to find an expanded directory for submodule WI-EJB-1.0-SNAPSHOT.jar but found a JAR.  If this is a directory deployment be sure to expand all submodules.

通过单击Netbeans中的“WE-EAR.ear”文件,可以看到它实际上包含“WI-EJB-1.0-SNAPSHOT.jar”,而不是扩展目录。我该如何解决这个问题?

最佳答案

必须更改EAR的pom.xml使其包含下面的模块部分-注意“unpack”命令。

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ear-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
        <version>5</version>
             <modules>
                    <webModule>
                        <groupId>com.mycompany</groupId>
                        <artifactId>WI-ENT-web</artifactId>
                        <unpack>true</unpack>
                        <!--<contextRoot></contextRoot>-->
                    </webModule>
                    <ejbModule>
                        <groupId>com.mycompany</groupId>
                        <artifactId>WI-EJB</artifactId>
                        <unpack>true</unpack>
                    </ejbModule>
               </modules>
    </configuration>
  </plugin>
</plugins>



在“依赖关系”部分下,确保声明类型-在我的情况下,问题是没有指定“ejb”类型。
  <dependencies>

    <dependency>
      <groupId>com.mycompany</groupId>
      <artifactId>WI-ENT-web</artifactId>
      <version>1.0-SNAPSHOT</version>
      <type>war</type>
    </dependency>

    <dependency>
      <groupId>com.mycompany</groupId>
      <artifactId>WI-EJB</artifactId>
      <version>1.0-SNAPSHOT</version>
      <type>ejb</type>
    </dependency>

  </dependencies>

关于jakarta-ee - Netbeans/Glassfish-预期会找到扩展目录,但找到了JAR,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27049120/

10-12 03:04