Configuring Vaadin without web.xml

There is always room for improvement in programming. After my initial post about configuring Vaadin in simple 6 steps, my friend indicated that we could use annotation based configuration to get rid of web.xml in our Vaadin configuration. Yes, he is right. It is possible to configure Vaadin with annotations. Let’s see how it is;

Step 1: Add Servlet API dependency into your pom.xml, and update your project’s configuration


Step 2: Modify your HelloWorldUI as follows

public class HelloWorldUI extends UI {
	public static class ExtendedVaadinServlet extends VaadinServlet {

	protected void init(VaadinRequest request) {
		Button btn = new Button("Click Me!");
		btn.addClickListener(new ClickListener() {
			public void buttonclick(ClickEvent event) {"Hello World!");

Step 3: Remove or comment out VaadinServlet configuration in web.xml

Just remove


elements in web.xml we had added in our previous post.

Now restart your web container, and try to access http://localhost:8080/helloworld URL to see the result. It should work as before.