Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

appengine-web.xml not being put in WEB-INF #63

Open
dclements opened this issue Dec 5, 2017 · 3 comments
Open

appengine-web.xml not being put in WEB-INF #63

dclements opened this issue Dec 5, 2017 · 3 comments

Comments

@dclements
Copy link

dclements commented Dec 5, 2017

This to me looks more or less identical to the README example. Am I missing something simple?

Bazel version:

$ bazel version
Build label: 0.8.0-homebrew
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Mon Nov 27 20:38:09 2017 (1511815089)
Build timestamp: 1511815089
Build timestamp as int: 1511815089

.bazelrc:

build --experimental_repository_cache=/Users/dclemen/.bazel/cache

Structure of project:

foo/
    BUILD
    WORKSPACE
    src/main/java/<various>/
        - VariousFiles.java
    src/test/java/<various>
        - VariousFilesTest.java
    webapp/
        WEB-INF/
            appengine-web.xml
            logging.properties
            web.xml

WORKSPACE:

git_repository(
    name = "io_bazel_rules_appengine",
    remote = "https://github.com/bazelbuild/rules_appengine.git",
    tag = "0.0.7",
)

load("@io_bazel_rules_appengine//appengine:appengine.bzl", "appengine_repositories")
appengine_repositories()

<various maven_jar definitions>

BUILD:

load("@io_bazel_rules_appengine//appengine:appengine.bzl", "appengine_war")

package(default_visibility = ["//visibility:public"])

java_library(
    name = "java-maven-lib",
    resources = glob(["src/main/resources/**"]),
    srcs = glob(["src/main/java/**/*.java"]),
    deps = [
      "//external:appengine/java/api",
      "@io_bazel_rules_appengine//appengine:javax.servlet.api",
      <additional jars>
    ]
)

appengine_war(
    name = "foo-gae",
    jars = [":java-maven-lib"],
    data = glob(["webapp/**"]),
    data_path = "webapp",
)

<test definition, which if removed renders the exact same result>

I build it and then run it (with bazel run //:foo-gae -- --port=12345), and it generates the following exception:

SEVERE: Received exception processing /private/var/tmp/_bazel_dclemen/7b6609c6dba886f72d542786a5989753/execroot/__main__/bazel-out/darwin-fastbuild/bin/foo-gae.runfiles/__main__/WEB-INF/appengine-web.xml
com.google.apphosting.utils.config.AppEngineConfigException: Could not locate /private/var/tmp/_bazel_dclemen/7b6609c6dba886f72d542786a5989753/execroot/__main__/bazel-out/darwin-fastbuild/bin/foo-gae.runfiles/__main__/WEB-INF/appengine-web.xml
	at com.google.apphosting.utils.config.AppEngineWebXmlReader.getInputStream(AppEngineWebXmlReader.java:141)
	at com.google.apphosting.utils.config.AppEngineWebXmlReader.readAppEngineWebXml(AppEngineWebXmlReader.java:75)
	at com.google.apphosting.utils.config.EarHelper.readWebModule(EarHelper.java:178)
	at com.google.appengine.tools.development.ApplicationConfigurationManager$WarModuleConfigurationHandle.readConfiguration(ApplicationConfigurationManager.java:414)
	at com.google.appengine.tools.development.ApplicationConfigurationManager.<init>(ApplicationConfigurationManager.java:159)
	at com.google.appengine.tools.development.ApplicationConfigurationManager.newWarConfigurationManager(ApplicationConfigurationManager.java:101)
	at com.google.appengine.tools.development.ApplicationConfigurationManager.newWarConfigurationManager(ApplicationConfigurationManager.java:87)
	at com.google.appengine.tools.development.DevAppServerImpl.<init>(DevAppServerImpl.java:142)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at com.google.appengine.tools.development.DevAppServerFactory.doCreateDevAppServer(DevAppServerFactory.java:271)
	at com.google.appengine.tools.development.DevAppServerFactory.access$000(DevAppServerFactory.java:33)
	at com.google.appengine.tools.development.DevAppServerFactory$1.run(DevAppServerFactory.java:233)
	at com.google.appengine.tools.development.DevAppServerFactory$1.run(DevAppServerFactory.java:231)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.google.appengine.tools.development.DevAppServerFactory.createDevAppServer(DevAppServerFactory.java:231)
	at com.google.appengine.tools.development.DevAppServerFactory.createDevAppServer(DevAppServerFactory.java:101)
	at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:347)
	at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:47)
	at com.google.appengine.tools.development.DevAppServerMain.run(DevAppServerMain.java:223)
	at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:214)
Caused by: java.io.FileNotFoundException: /private/var/tmp/_bazel_dclemen/7b6609c6dba886f72d542786a5989753/execroot/__main__/bazel-out/darwin-fastbuild/bin/foo-gae.runfiles/__main__/WEB-INF/appengine-web.xml (No such file or directory)
	at java.io.FileInputStream.open0(Native Method)
	at java.io.FileInputStream.open(FileInputStream.java:195)
	at java.io.FileInputStream.<init>(FileInputStream.java:138)
	at java.io.FileInputStream.<init>(FileInputStream.java:93)
	at com.google.apphosting.utils.config.AppEngineWebXmlReader.getInputStream(AppEngineWebXmlReader.java:137)
	... 22 more

com.google.apphosting.utils.config.AppEngineConfigException: Invalid configuration
	at com.google.appengine.tools.development.DevAppServerImpl.reportDeferredConfigurationException(DevAppServerImpl.java:432)
	at com.google.appengine.tools.development.DevAppServerImpl.doStart(DevAppServerImpl.java:232)
	at com.google.appengine.tools.development.DevAppServerImpl.access$000(DevAppServerImpl.java:47)
	at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:219)
	at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:217)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:217)
	at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:359)
	at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:47)
	at com.google.appengine.tools.development.DevAppServerMain.run(DevAppServerMain.java:223)
	at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:214)
Caused by: com.google.apphosting.utils.config.AppEngineConfigException: Invalid appengine-web.xml(/private/var/tmp/_bazel_dclemen/7b6609c6dba886f72d542786a5989753/execroot/__main__/bazel-out/darwin-fastbuild/bin/foo-gae.runfiles/__main__/WEB-INF/appengine-web.xml) - Could not locate /private/var/tmp/_bazel_dclemen/7b6609c6dba886f72d542786a5989753/execroot/__main__/bazel-out/darwin-fastbuild/bin/foo-gae.runfiles/__main__/WEB-INF/appengine-web.xml

When I open up bazel-bin/foo-gae.war: I see the following structure:

/
    appengine-web.xml
    logging.properties
    web.xml
    WEB-INF/
        lib/
            - various.jar
@dclements
Copy link
Author

dclements commented Dec 6, 2017

On inspection I found that in _war_impl on the relative path code it was producing foo-gae.wa/webapp which looked… suspicious. So I substituted it out with foo-gae.war/webapp directly in the code. This caused build the war correctly, but it still wouldn't run with bazel run, giving the same error reported above. When I replaced it with just webapp it seems to have created the war successfully and launches more-or-less correctly (there's a classloader problem, but that may be a configuration on my end).

@ittaiz
Copy link
Member

ittaiz commented May 8, 2018

@dclements do you happen to have a branch of this online? Or can point me to the specific place you changed? I'm seeing the issue but couldn't find what you're talking about

@pmbethe09
Copy link
Member

Well at HEAD with a recent bazel on linux or Mac I can
bazel run //examples/java:examples

and it works fine.

Looking at the example you have
jars = [":java-maven-lib"],

in your
appengine_war

Maybe we should try and fix it for you -- but as-is you need to specify the '_deploy.jar' which is an implicit output that creates a mega-jar from all of the small per-lib jars.

So change to

jars = [":java-maven-lib_deploy.jar"],

and try again

pmbethe09 pushed a commit that referenced this issue Jul 5, 2018
I was getting the same error as reported in #63. This was fixed for me by adding a "/' to the data_path, just like the examples folder rule does.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants