polymer template file not found if PolymerTemplate java class is referenced in a spring managed bean
See original GitHub issueSteps to reproduce:
- A spring application using Vaadin 14.x
- A PolymerTemplate component declared as:
@Tag("my-template")
@JsModule("./src/my-template.js")
public class MyTemplate extends PolymerTemplate<MyTemplate.MyTemplateModel> {
......
}
- A managed bean component containing the PolymerTemplate and the interface used to autowire the bean
public interface SomeInterface {
Component asComponent();
}
@SpringComponent
@Scope("prototype")
public class SomeManagedBean extends VerticalLayout implements SomeInterface {
public SomeManagedBean() {
add(new MyTemplate());
}
@Override
public Component asComponent() {
return this;
}
}
and finally the Route class:
@Route
@PWA(name = "Project Base for Vaadin Flow with Spring", shortName = "Project Base")
public class MainView extends VerticalLayout {
public MainView(SomeInterface someInterface) {
this.someInterface = someInterface;
add(someInterface.asComponent());
}
}
When running the app and navigating to the MainView route, an exception is thrown complaining:
Couldn't find the definition of the element with tag 'my-template' in any template file declared using '@JsModule' annotations
Minimal project to reproduce the issue skeleton-starter-flow-spring-polymertemplate-spring-managed-bean.zip
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Spring/Eclipse 'referenced bean not found' warning when ...
I have an (admittedly cosmetic) issue with the Spring IDE plugins for Eclipse that I've not been able to solve. I have a...
Read more >Super simple approach to accessing Spring beans from non ...
How can I inject Spring managed beans into POJO's and classes not managed by Spring? Solution. Researching this question turned up several ...
Read more >Chapter 3. Beans, BeanFactory and the ApplicationContext
Most Spring users use a BeanFactory or ApplicationContext variant which supports XML format configuration files. Each bean has dependencies expressed in the ...
Read more >Using CDI Beans | CDI | Integrations | Vaadin Docs
The framework uses the CDI BeanManager to get references to beans. ... into template classes using the @id annotation become managed beans ......
Read more >A Quick Guide to Spring @Value - Baeldung
Learn to use the Spring @Value annotation to configure fields from property files, system properties, etc.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Before the fix it doesn’t matter which mode you are running the app. It always uses byte code scanner.
With the fix dev mode is using full CP scanning, production mode is using byte code scanning. It may be changed with the parameter
optimizeBundle
.I don’t follow the releases so I don’t know which release has the fix. Please use the releases page and check which version contains the fix. https://github.com/vaadin/flow/releases
https://github.com/vaadin/flow-and-components-documentation/blob/master/documentation/production/tutorial-production-mode-advanced.asciidoc#goal-parameters-1 (
optimizeBundle
) https://github.com/vaadin/flow-and-components-documentation/blob/master/documentation/advanced/tutorial-all-vaadin-properties.asciidocDuplicate of #5658 which is fixed.