Thanks for ynov's answer. It helps and works. But it is not so elegant.
Another workaround is stated here regarding Deploying my application at the root in Tomcat: configure the context root in conf/server.xml
to use your app:
<Context path="" docBase="polymer" debug="0" reloadable="true"></Context>
However, as stated in the Apache Tomcat 7 Configuration Reference - The Context Container:
It is NOT recommended to place elements directly in the server.xml file. This is because it makes modifying the Context configuration more invasive since the main conf/server.xml file cannot be reloaded without restarting Tomcat.
The actual problem of polymer-starter-kit cannot be properly deployed as a webapp on Tomcat is remained in the polymer-starter-kit source code. The website is not shown properly is because the resources (htmls, images, components, etc...) are not refered correctly.
In the originall code of polymer-starter-kit/index.html, the resources are linked like the following:
...
<!-- Homescreen icons -->
<link rel="apple-touch-icon" href="/images/manifest/icon-48x48.png">
<link rel="apple-touch-icon" sizes="72x72" href="/images/manifest/icon-72x72.png">
<link rel="apple-touch-icon" sizes="96x96" href="/images/manifest/icon-96x96.png">
<link rel="apple-touch-icon" sizes="144x144" href="/images/manifest/icon-144x144.png">
<link rel="apple-touch-icon" sizes="192x192" href="/images/manifest/icon-192x192.png">
...
However, if you deploy the webapp in a sub directory $TOMCAT/webapps/
like $TOMCAT/webapps/polymer
, the link reference like href="/images/manifest/icon-48x48.png"
won't work, because it refers to the root directory. This is why the previous workarounds (i.e., put the webapp at $TOMCAT/webapps/ROOT
) work. So, the trick is change the link to href="images/manifest/icon-48x48.png"
(or any other proper path suitable to the correct path of the resources you want ot use.).
For example, in polymer-starter-kit/index.html
:
...
<!-- Homescreen icons -->
<link rel="apple-touch-icon" href="images/manifest/icon-48x48.png">
<link rel="apple-touch-icon" sizes="72x72" href="images/manifest/icon-72x72.png">
<link rel="apple-touch-icon" sizes="96x96" href="images/manifest/icon-96x96.png">
<link rel="apple-touch-icon" sizes="144x144" href="images/manifest/icon-144x144.png">
<link rel="apple-touch-icon" sizes="192x192" href="images/manifest/icon-192x192.png">
...
because images/
and index.html
are under same directory.