Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
CDIUI and Custom Servlets
Hi, I have two different UI and I want just one of them to have a custom Servlet, but I can't get it to work. This is my configuration for UI1:
@Title("Title 1")
@Theme("theme1")
@CDIUI("")
@Push(transport= Transport.LONG_POLLING)
@PreserveOnRefresh
public final class UI1 extends UI
{
// Nothing more relevant. No servlet definition
}
And configuration for UI2:
@Title("Title 2")
@CDIUI("UITWO")
@Push(transport= Transport.LONG_POLLING)
@PreserveOnRefresh
public final class UI2 extends UI
{
@WebServlet(urlPatterns = "/UITWO", asyncSupported = true, initParams = {
@WebInitParam( name = Constants.SERVLET_PARAMETER_HEARTBEAT_INTERVAL, value = "30"),
@WebInitParam( name = Constants.SERVLET_PARAMETER_CLOSE_IDLE_SESSIONS, value = "true")
})
@VaadinServletConfiguration(productionMode = false, ui = UI2.class)
public static class Servlet extends VaadinCDIServlet
{
}
...
}
But his doesn't work. When I go to http://localhost:8080/context/ I have an 404 and when I go to http://localhost:8080/context/UITWO I get a "Failed to load bootstrap".
If I remove the Servlet definition in UI2, everything works fine and I can access both UIs on those addresses.
What is the correct way to do this?
Try with something like this:
@CDIUI("/")
public class UI1 extends UI {
@Override
protected void init(VaadinRequest vaadinRequest) { setContent(new Label("UI1")); }
@WebServlet(urlPatterns = {"/*", "/VAADIN/*"}, asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = UI1.class)
public static class Servlet extends VaadinCDIServlet { }
}
and:
@CDIUI("ui2")
public class UI2 extends UI {
@Override
protected void init(VaadinRequest vaadinRequest) { setContent(new Label("UI2")); }
@WebServlet(urlPatterns = "/ui2/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = UI2.class)
public static class Servlet extends VaadinCDIServlet { }
}