Blixt
Blixt

Reputation: 50197

How do I use app.yaml with Java runtime in App Engine v1.9.18?

I followed the documentation for using app.yaml with Java which claims that this should work and that it will generate web.xml and appengine-web.xml automatically. However, it doesn't seem to work and it doesn't mention which tool will generate the files.

I first tried a mvn clean install which errors out because the .xml files are missing:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.4:war (default-war) on project roger-analytics: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]

I then tried to run the local development server:

$ gcloud preview app run app.yaml
ERROR: (gcloud.preview.app.run) An error occurred while parsing file: [/Users/blixt/src/roger-api/module_analytics/app.yaml]
Unexpected attribute 'servlet' for object of type URLMap.
  in "/Users/blixt/src/roger-api/module_analytics/app.yaml", line 7, column 12

(I get the same error from dev_appserver.py . by the way)

It appears that app.yaml isn't supported after all. Am I missing something, or was support removed without updating the documentation?

Here's my app.yaml file, which is intended to run as a module in my Google Cloud App Engine project (along with other modules that have Python and Go runtimes):

module: analytics
runtime: java
api_version: 1

handlers:
- url: /*
  servlet: im.rgr.roger.RogerAnalytics
  login: admin
  secure: always

system_properties:
  java.util.logging.config.file: WEB-INF/logging.properties

Upvotes: 5

Views: 907

Answers (1)

Nick
Nick

Reputation: 3591

There are several issues at play here. I'll describe various facts that group together to create a constellation of SDK edge-case goodness (this information is current as of SDK 1.9.21):

  • In order to deploy using the Java SDK's appcfg.sh, you'll need to have app.yaml inside the war/WEB-INF/ folder.

  • appcfg.py complains Unexpected attribute 'servlet' for object of type URLMap..

  • gcloud preview app deploy uses appcfg.py (or the same codebase) and therefore also complains in the same manner


So, in conclusion, you'll need to use appcfg.sh

Upvotes: 2

Related Questions