Jim
Jim

Reputation: 21

Routing with Polymer app on Google Appengine server

I'm facing a problem on Google Appengine server and didn't find any solutions, maybe some one could help me.

I have developp an polymer app with his own router, so all routing is done client side. When I refresh the page the request is handle by the server and didn't works correctly because no route match.

To solve it I have set in web.xml file that I want always serve the index.html file whitout take care of the url, see below the code :

<!-- Always serve the index.html file if url is not defined in web.xml (It's polymer router, which will manage routing) -->
<servlet>
    <servlet-name>app</servlet-name>
    <jsp-file>/index.html</jsp-file>
</servlet>
<servlet-mapping>
    <servlet-name>app</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>


<welcome-file-list>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>

This works as expected on local, but when I deploy on production environment I got the following error :

java.lang.IllegalStateException: No forced path servlet for index.html

I have looking for a solution but I didn't fin anything, if someone has an idea I take it!

Have a nice day!

Upvotes: 2

Views: 103

Answers (1)

Frank R.
Frank R.

Reputation: 1832

This is nothing to do with Polymer. You need to focus on the gae error.

java.lang.IllegalStateException: No forced path servlet for index.html

Can you try this? GAE No forced path servlet for xxx.jsp

If it doesn't work, you can create a servlet to forward requests. e.g.

Replace

<jsp-file>/index.html</jsp-file>

with the servlet

<servlet-class>your.package.YourServlet</servlet-class>

Override doGet in your.package.YourServlet

getServletContext().getRequestDispatcher("/index.html").forward(req, res);

See also https://issuetracker.google.com/issues/35884280#comment7, and https://issuetracker.google.com/issues/35884280#comment8

Upvotes: 1

Related Questions