I wasn't able to successfully integrate the official Vaadin-CDI-Integration-Addon, since after finishing the official integration instructions, the following Exception
was thrown in case I reloaded the already published URL localhost:8080/App/?restartApplication
.
javax.servlet.ServletException: com.vaadin.server.ServiceException:
java.lang.IllegalStateException: UI id has already been defined
The following little workaround is a tested, working solution, which completes the official instructions.
You have to work off the following steps to successfully integrate the official CDI-Integration-Addon into your Vaadin project.
- Do exactly as stated in the official how-to.
- Remove the
?restartApplication
parameter from the URL. This avoids the Exception
.
- Inject the EJB as shown in the listing below.
- Keep in mind to restart your application manually if necessary!
@CDIUI
public class ExampleCDIUI extends UI {
@Inject
MyLocalBeanInterface myBean;
@Override
public void init(VaadinRequest request) {
Label label = new Label("Hello Vaadin user");
setContent(label);
// myBean should be accessible now.
}
}
That's it. I hope this helps :-)