在多模块 Google AppEngine 中获取资源文件

Get resource file in multi-module Google AppEngine

我正在关注这个文档: https://cloud.google.com/appengine/docs/java/config/appconfig#Static_Files_and_Resource_Files 像这样设置特定的资源文件位置:

appengine-web.xml:

<resource-files>
        <include path="/resources/*" />
</resource-files>

现在,我需要在 servlet 上下文之外获取资源文件。所以,我试图通过以下方式获取文件:

InputStream jsonResource = new FileInputStream("default/WEB-INF/resources/" + resourceName);

这在本地开发服务器上运行良好,但在生产中,我得到一个 IOException:

getResourceAsString: /base/data/home/apps/s~my-app-id/module2:multi-module-1.384597049666152751/default/WEB-INF/resources/query_url.json (No such file or directory)

这是我的 GAE 模块结构:

root-ear
 - default
   - src/main/webapp/WEB-INF
     - resources
   - src/main/java (some code)
 - module2
   - src/main/java (code that needs the resource)

我看错文件了吗?资源文件的正确路径应该是什么?

其他详情:

当前目录包含"WEB-INF"和“_ah”文件夹。

以下是 WEB-INF 中的结构:

WEB-INF
 - <all my files from my normal WEB-INF>
 - resources <<< The folder I added under <resource-files>
 - lib
 - classes
 - appengine-generated

我能够通过使用以下代码段列出本地文件来解决这个问题:

File curDir = new File("./WEB-INF");
File[] files = curDir.listFiles();
for (File file: files) {
  logger.info(file.getName());
}