question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

polymer template file not found if PolymerTemplate java class is referenced in a spring managed bean

See original GitHub issue

Steps to reproduce:

  1. A spring application using Vaadin 14.x
  2. A PolymerTemplate component declared as:
@Tag("my-template")
@JsModule("./src/my-template.js")
public class MyTemplate extends PolymerTemplate<MyTemplate.MyTemplateModel> {
......
}
  1. 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:closed
  • Created 4 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
denis-anisimovcommented, Oct 1, 2019

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.asciidoc

0reactions
denis-anisimovcommented, Apr 13, 2021

Duplicate of #5658 which is fixed.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found