Appengine Modules Maven Error during DevSever Goal

2019-04-13 14:13发布

问题:

i have been trying to run a new project with modules support, but am getting following error all the time, unable to debug it,

com.google.apphosting.utils.config.EarHelper reportConfigException [INFO] INFO: Application directory 'path-to-project/DemoEar-1.0.0-SNAPSHOT/DemoWarApp' must exist and be a directory.

my module structure is below

main application.xml contains

 <module>
 <web>
 <web-uri>DemoWarApp</web-uri>
 <context-root>DemoWarApp</context-root>
</web>
</module>

its clearly not pointing to the proper war folder path. does anyone know how to fix it?

Thanks

回答1:

The bundle folder that is created must match the web-uri in your application.xml. So, you either change the bundle folder name with bundleFileName in the maven-ear-plugin

<modules>
        <webModule>
            <groupId>groupId-of-DemoWarApp</groupId>
            <artifactId>artifactId-of-DemoWarApp</artifactId>
            <bundleFileName>DemoWarApp</bundleFileName>
        </webModule>
</modules>

or you change the web-uri to {module-name}-{version} every time to match the created bundle folder name.

I would recommend a version independent bundle bundleFileName (that is the same as your web-uri) so you don't have to bother with it when the version changes.

Complete ear plugin snippet:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ear-plugin</artifactId>
    <version>2.9</version>
    <configuration>
      <modules>
        <webModule>
            <groupId>groupId-of-DemoWarApp</groupId>
            <artifactId>artifactId-of-DemoWarApp</artifactId>
            <bundleFileName>DemoWarApp</bundleFileName>
        </webModule>
      </modules>
      <version>5</version>
      <defaultLibBundleDir>lib</defaultLibBundleDir>
      <unpackTypes>war</unpackTypes>
    </configuration>
</plugin>