Search code examples
javagoogle-app-enginemavenwebjars

How to use Google App Engine with Webjars?


I have a Google App Engine (1.8.5) project. I would like to serve up static Javascript & CSS via Webjars. However, I keep getting HTTP 404 errors. How do I make my Webjars files accessible?

My src/main/webapp/WEB-INF/appengine-web.xml per Google's documentation:

<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
    ...
    <static-files>
        <include path="/resources/**" />
        <include path="/webjars/**" />
    </static-files>
</appengine-web-app> 

My src/main/webapp/index.html, referencing the Webjars-provided Bootstrap CSS file:

<html>
<head>
    <link rel="stylesheet" href="webjars/bootstrap/3.0.0/css/bootstrap.min.css">
</head>
...
</html>

Snippets of pom.xml:

    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>(lots)</artifactId>
        <version>1.8.5</version>
    </dependency>
    <dependency>
        <groupId>com.google.inject</groupId>
        <artifactId>guice</artifactId>
        <version>4.0-beta</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <scope>provided</scope>
        <version>3.1.0</version>
    </dependency>
    <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>bootstrap</artifactId>
        <version>3.0.0</version>
    </dependency>

This is my first GAE posted question, so I'm not sure what additional info to provide--be gentle, SO.


Solution

  • Unfortunately, Webjars requires a Servlet 3.x container, but the Google App Engine is currently still only on version 2.5.

    You might want to star this issue in the GAE issues list.