Netbeans / Glassfish - 预计会找到一个扩展的目录,但找到了一个JAR [英] Netbeans/Glassfish - Expected to find an expanded directory but found a JAR
问题描述
该项目似乎基于以下URL中的文档构建为企业应用程序:
https://netbeans.org/kb/docs/javaee/ maven-entapp.html#intro
该项目包含以下5个模块:
<$ p $ WI-EAR
WI-EJB
WI-Enterprise
WI-ENT-web
WE-Web
$ c $根据上面引用的教程,用于从Netbeans运行和部署的项目是-EAR项目。
当我右键单击WI-EAR项目节点并选择Build with Dependencies时,根据本教程,我得到以下结果:
Reactor概要:
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文件。
到目前为止这么好。接下来,再次按照教程,我右键单击Projects窗口中的EAR项目节点,然后选择Run。
然而,此时GlassFish控制台显示以下内容错误:
SEVERE:部署应用程序时出现异常
java.lang.IllegalArgumentException:预计会找到展开的目录子模块WI-EJB-1.0-SNAPSHOT.jar,但找到了JAR。如果这是目录部署,请确保展开所有子模块。
通过点击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>
<配置>
< version> 5< / version>
<模块>
< 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类型。
<依赖关系>
< dependency>
< groupId> com.mycompany< / groupId>
< artifactId> WI-ENT-web< / artifactId>
< version> 1.0-SNAPSHOT< / version>
< type> war< / type>
< /依赖关系>
< dependency>
< groupId> com.mycompany< / groupId>
< artifactId> WI-EJB< / artifactId>
< version> 1.0-SNAPSHOT< / version>
< type> ejb< / type>
< /依赖关系>
< /依赖关系>
I'm trying to deploy a Netbeans/Glassfish project on my local PC. It's currently running in production
The project appears to be structured as an Enterprise application based on docs found at this url:
https://netbeans.org/kb/docs/javaee/maven-entapp.html#intro
The project has the following 5 modules:
WI-EAR
WI-EJB
WI-Enterprise
WI-ENT-web
WE-Web
According to the above referenced tutorial, the project that is used to run and deploy from Netbeans is the "-EAR" project.
When I right-click the WI-EAR project node and choose Build with Dependencies, per the tutorial, I get this result:
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
I can see the created .ear file in the "target" directory, under the name "WI-EAR".
So far so good. Next, again per the tutorial, I right-click the EAR project node in the Projects window and choose Run.
At this point, however, the GlassFish console displays the following error:
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.
By clicking on the "WE-EAR.ear" file within Netbeans, I can see that it in fact does contain "WI-EJB-1.0-SNAPSHOT.jar", as opposed to an expanded directory. How can I resolve this problem?
Had to change the EAR's pom.xml to include the modules section below - note the "unpack" command.
<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>
ALSO
Under the dependencies section, make sure to declare the types - in my case the problem was that there wasn't an "ejb" type specified.
<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>
这篇关于Netbeans / Glassfish - 预计会找到一个扩展的目录,但找到了一个JAR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!