CustomComponent web.xml


I’m using vaadin 6 and I have this code

MainPage extends Application

and my web.xml is


now I change my code to:

MainPage extends CustomComponent

and the problem is I need to change my web.xml because I have this error.

javax.servlet.ServletException: java.lang.ClassCastException: MainPage cannot be cast to com.vaadin.Application

What will be my com.vaadin.terminal.gwt.server.ApplicationServlet???

The root of your application needs to be a class that extends the Application class. It is this one that is defined in the web.xml. In other words, the servlet expect a class of type Application, but since you are now extending CustomComponent, it cannot be casted to an Application.

What you need to do, is still have an application class that is deinfed in the web.xml and the use the MainPage (which extends CustomComponent) in the application class. Something along the lines of this: class MyApplication extends Application { public void init() { ... MainPage mainPage = new MainPage(); Window window = new Window(); window.addComponent(mainPage); setMainWindow(window); } }

Then reference MyApplication in your web.xml.

Wow… that’s a big help… Thank you Kim…!! :slight_smile: