Vaadin I18N Provider is not instantiated even though it should #38726
-
I am trying to use a custom vaadin i18nProvider however it will never be picked up as a been: @VaadinServiceEnabled
@VaadinServiceScoped
public class CustomI18NProvider implements I18NProvider {
@Override
public List<Locale> getProvidedLocales() {
return List.of(Locale.ENGLISH, Locale.GERMAN);
}
@Override
public String getTranslation(String s, Locale locale, Object... objects) {
return "Bla";
}
} During debugging i even get a ClassNotFoundException even though the class is there on the classpath. A lot of other beans load correctly, i tried a ton of combinations for annotations. I debugged into the QuarkusInstantiator and all requirements are met except that the bean is just not there. When i try to search for in in debugging i get the ClassNotFound described above. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
Are you using a Vaadin Quarkus extension? Is it with the JVM or as a native executable? |
Beta Was this translation helpful? Give feedback.
-
I got it working, or at least I have a workaround:
@VaadinServiceEnabled
@VaadinServiceScoped
@Default
public class CustomI18NProvider implements I18NProvider { |
Beta Was this translation helpful? Give feedback.
-
Still nowadays (Oct 27 of 2024) on Vaadin v 24.5.0 + Quakus 3.15.1 I had to add the
Implementation:
|
Beta Was this translation helpful? Give feedback.
Yeah so your problem is that beans that look useless to our CDI layer are removed. That's why adding an injection point somewhere makes it work as when the injection point is detected, it says our CDI layer that the bean is consumed and shouldn't be removed.
Most probably, Vaadin is checking the beans dynamically without an injection point.
What you can do for the time being is add the
@Unremovable
annotation to your bean and drop the injection point you added.I think it's also worth reporting this issue to the Vaadin extension author so that they make use of the
UnremovableBeanBuildItem
to mark the beans they actively consume as unremovable automatically.HTH.