I have installed all required packages for polymer.
I downloaded polymer-starter-kit and build it.
If I start polymer serve
, I can get the page similar like following:
However, if I copy the folder /build/bundled
under my polymer app directory, to the place /path/to/tomcat/webapps
, the page I get is only grep background, nothing more.
I would like to know how to properly deploy a polymer app on tomcat.
If I just build
a very very simple polymer with only one element instead of the polymer-starter-kit, after copying the /build/bundled
into /path/to/tomcat/webapps
, the page can be shown properly.
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:However, as stated in the Apache Tomcat 7 Configuration Reference - The Context Container:
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:
However, if you deploy the webapp in a sub directory
$TOMCAT/webapps/
like$TOMCAT/webapps/polymer
, the link reference likehref="/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 tohref="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
:because
images/
andindex.html
are under same directory.