How to integrate Vaadin with Quarkus

This topic is the discussion thread for the Vaadin documentation page How to integrate Vaadin with Quarkus.

Questions, feedback, and comments are welcome here.

Can't get CDI to work with @VaadinServiceEnabled. I want to register beforeEnterListener to UI and use AccessAnnotationChecker to restrict access to views based on roles.

@VaadinServiceEnabled
public class ConfigureUIServiceInitListener implements VaadinServiceInitListener { 
  @Override
  public void serviceInit(ServiceInitEvent event) { ... }
}


serviceInit() is never called unless I register it as described here: https://vaadin.com/docs/latest/advanced/service-init-listener, which is the method for plain applications, not CDI or Quarkus apps? Or?

Adding https://vaadin.com/directory/component/vaadin-cdi to pom screws up, unsurprisingly.

I believe if I could have it registered in Quarkus it'd also be possible to inject OidcClient, which could provide useful.

EDIT: However, when I have

@VaadinServiceEnabled
@VaadinServiceScoped
@Unremovable
public class I18NProviderImpl implements I18NProvider {

the warning i usually get on startup

Can't find any @VaadinServiceScoped bean implementing 'I18NProvider'.

go away.

Why does one work and not the other?

https://vaadin.com/docs/latest/advanced/service-init-listener, which is the method for plain applications, not CDI or Quarkus apps? Or?

The Java Service Provider Interface is a mechanism that works in plain Java applications as well as in CDI environments. So yes, this is the right way to register SPI.

Why does one work and not the other?

While the class ConfigureUIServiceInitListener is a SPI, the class I18NProviderImpl is a CDI bean. So both techniques are different.

`@Unremovable` is required for because the bean instance is looked up programmatically by Vaadin. If you don't add it, Quarkus will not find it referenced anywhere and it removes the bean completely. In addition you don't need to mark it as `@VaadinServicrScoped` since it is already `@VaadinServiceEnabled`

See note on https://vaadin.com/docs/latest/flow/integrations/quarkus#vaadin-cdi-features paragraph