Netbeans/Glassfish - Expected to find an expanded directory but found a JAR

前提是你 提交于 2019-12-07 04:46:33

问题


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?


回答1:


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>


来源:https://stackoverflow.com/questions/27049120/netbeans-glassfish-expected-to-find-an-expanded-directory-but-found-a-jar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!