Flow: Polymer Template cannot be found when inside a dependecy

Created on 25 May 2018  路  5Comments  路  Source: vaadin/flow

Description of the bug

Polymer Template cannot be found as soon as it is part of a dependency. The reason for this might be my own fault f.e. maybe @HTMLImport should not be used by addons?, or rather the lack of documentation for this very specific case. I would be really glad if somebody could help me out on this.

Minimal reproducible example

An example project can be found here to get the two behaviours:

  • run an install goal on the parent module
  • execute jetty:run on the addon module the template is found
  • execute jetty:run on the demo module the template cannot be found

Expected behavior

The template should be found.

Actual behavior

java.lang.IllegalStateException: Can't find resource 'context://iron-dropdown-wrapper/iron-dropdown-animation.html' via the servlet context
    at com.vaadin.flow.component.polymertemplate.DefaultTemplateParser.getTemplateContent(DefaultTemplateParser.java:104)
    at com.vaadin.flow.component.polymertemplate.TemplateDataAnalyzer.parseTemplate(TemplateDataAnalyzer.java:185)
    at com.vaadin.flow.component.polymertemplate.TemplateInitializer.<init>(TemplateInitializer.java:93)
    at com.vaadin.flow.component.polymertemplate.PolymerTemplate.<init>(PolymerTemplate.java:97)
    at com.vaadin.flow.component.polymertemplate.PolymerTemplate.<init>(PolymerTemplate.java:112)
    at com.github.appreciated.dropdown.IronDropdownWrapper.<init>(IronDropdownWrapper.java:30)
    at com.github.appreciated.dropdown.IronDropdownWrapper.<init>(IronDropdownWrapper.java:27)
    at com.github.appreciated.MainView.getIronDropDown(MainView.java:54)
    at com.github.appreciated.MainView.<init>(MainView.java:30)
    ... 48 more
question

All 5 comments

I think you have the local frontend resources in the wrong location and those are not picked for the jar but instead for a war they would be. You should put them to src/main/resources/META-INF/resoures/frontend, see example from Grid: https://github.com/vaadin/vaadin-grid-flow/tree/master/src/main/resources/META-INF/resources/frontend

The tutorial https://vaadin.com/docs/v10/flow/web-components/creating-an-in-project-web-component.html describes how to make a component for a webapp project. There the files are put to the /webapp/ folder. I actually don't see any place where we mention that where you should put the files when you make an add-on that has local resources that should go to a jar artifact.

Maybe we should add documentation / tutorial for this, if this was the issue. Thus an issue for vaadin/flow-and-components-documentation repository would be great.

@pleku First of all thank you very much this worked! Now the template is found in the dependency but it isn't found in the addon module itself anymore. Which isn't ideal since I would need to duplicate the files to run the DemoView in the module itself.

Couldn't this be done more ideal by using a Maven plugin?

But it isn't found in the addon module itself anymore

I think you need to define the resourceBase for the add-on module, see: https://github.com/vaadin/vaadin-grid-flow/blob/master/pom.xml#L123

You indeed are a champ thanks again for your time!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Artur- picture Artur-  路  4Comments

pleku picture pleku  路  4Comments

mstahv picture mstahv  路  3Comments

stefanuebe picture stefanuebe  路  4Comments

knoobie picture knoobie  路  4Comments