Vaadin service interfaces as a CDI bean

Some Vaadin service interfaces can be implemented as a CDI bean. This way there is no need to register your implementation in the framework, and it became a managed bean with CDI features. Interfaces looked up by the add-on:

  • I18NProvider

  • Instantiator

  • SystemMessagesProvider

  • ErrorHandler

Beans have to be qualified by @VaadinServiceEnabled to be picked up.

Example of a SystemMessagesProvider:

public class TestSystemMessagesProvider implements SystemMessagesProvider {

    public SystemMessages getSystemMessages(SystemMessagesInfo systemMessagesInfo) {
        CustomizedSystemMessages messages = new CustomizedSystemMessages();
        messages.setInternalErrorMessage("Sorry, something went wrong :(");
        return messages;
@VaadinServiceScoped context’s purpose is to define a context with the lifespan of the Vaadin Service. It is not mandatory for these kind of beans, but other Vaadin contexts likely cause issues. There is no guarantee that an active vaadin session, or ui context exists during the add-on looks up any of these beans. Standard CDI @Dependent, and @ApplicationScoped contexts are safe too.