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.
Start Vaadin application from servlet
Hi,
I created an application which started as a conventional servlet. From within the start servlet I would like to forward to the Vaadin part of the application, because I would like to keep the request object.
Unfortunately I did not find a good solution for this. Finally I get an error message: Failed to load the widgetset: ...
In detail I have tried these steps:
1. Create a new Vaadin project named "VaadinTest"
2. Create a servlet "Dispatcher"
package com.example.vaadintest;
...
public class Dispatcher extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
...
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
RequestDispatcher dispatcher = request.getRequestDispatcher("/Vaadin.do");
dispatcher.forward(request, response);
...
3. Extend web.xml - note the changes in url-pattern
<servlet>
<servlet-name>Dispatcher</servlet-name>
<display-name>Dispatcher</display-name>
<description>Dispatcher</description>
<servlet-class>com.example.vaadintest.Dispatcher</servlet-class>
</servlet>
<servlet>
<servlet-name>Vaadintest Application</servlet-name>
<servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
<init-param>
<description>Vaadin application class to start</description>
<param-name>application</param-name>
<param-value>com.example.vaadintest.VaadintestApplication</param-value>
</init-param>
<init-param>
<description>Application widgetset</description>
<param-name>widgetset</param-name>
<param-value>com.example.vaadintest.widgetset.VaadintestWidgetset</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Vaadintest Application</servlet-name>
<url-pattern>/Vaadin.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Dispatcher</servlet-name>
<url-pattern>/Dispatcher.do</url-pattern>
</servlet-mapping>
4. Start application with http://myhost/Dispatcher.do
After a few seconds an error box appears on the screen: Failed to load the widgetset: ...
Does anyone know the right way?
Thanks, Thorsten
••••••••••
Eclipse 3.5.1 • Vaadin 6.2.6 • Vaadin Eclipse Integration 1.2.0 • Java 1.5
Windows XP/2000 • IE6/7 • Tomcat 6.0
Try adding a /VAADIN/* mapping to application servlet.
Joonas Lehtinen: Try adding a /VAADIN/* mapping to application servlet.
So I tried this:
<servlet-mapping>
<servlet-name>Vaadintest Application</servlet-name>
<url-pattern>/VAADIN/*</url-pattern>
<url-pattern>/Vaadin.do</url-pattern>
</servlet-mapping>
There's a little enhancement: the small Vaadin loading animation now appears on the screen. But then the same error message again. Did I misunderstood your suggestion?
Thorsten
Thorsten A: There's a little enhancement: the small Vaadin loading animation now appears on the screen. But then the same error message again. Did I misunderstood your suggestion?
No - I misread your web.xml. You are using your own widgetset? That widgetset must also be available under /VAADIN - now it seems that it is not.
Joonas Lehtinen: You are using your own widgetset? That widgetset must also be available under /VAADIN - now it seems that it is not.
Do you mean this part of the web.xml?
<init-param>
<description>Application widgetset</description>
<param-name>widgetset</param-name>
<param-value>com.example.vaadintest.widgetset.VaadintestWidgetset</param-value>
</init-param>
Actually I'm not using my own widgetset, but this web.xml entry was inserted automatically somehow. Anyway, I deleted these lines of code.
Now there is a new effect :(
When I start the application an error notification appears: Commuinication problem Take note of any unsaved data, and click here to continue.
When I click there, the message reappears...
Joonas Lehtinen: Try changing /Vaadin.do to /Vaadin.do/*
Great! It works fine now with these entries in web.xml:
...
<servlet-mapping>
<servlet-name>Vaadintest Application</servlet-name>
<url-pattern>/Vaadin.do/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Vaadintest Application</servlet-name>
<url-pattern>/VAADIN/*</url-pattern>
</servlet-mapping>
...
Thanks a lot for your help!
Thorsten