hello, i am new to vaadin i have compiled 2 codes one is
import com.vaadin.ui.Label;
import com.vaadin.ui.Window;
@SuppressWarnings("serial")
public class HelloWorld extends com.vaadin.Application {
/**
* Init is invoked on application load (when a user accesses the application
* for the first time).
*/
@Override
public void init() {
// Main window is the primary browser window
final Window main = new Window("Hello window");
setMainWindow(main);
// "Hello world" text is added to window as a Label component
main.addComponent(new Label("Hello World!"));
}
}
it compiles and works fine the other is
import com.vaadin.terminal.ExternalResource;
import com.vaadin.ui.MenuBar;
import com.vaadin.ui.MenuBar.Command;
import com.vaadin.ui.MenuBar.MenuItem;
import com.vaadin.ui.VerticalLayout;
@SuppressWarnings("serial")
public class MenuApplication extends VerticalLayout {
private MenuBar menubar = new MenuBar();
public MenuApplication() {
// Save reference to individual items so we can add sub-menu items to
// them
final MenuBar.MenuItem file = menubar.addItem("File", null);
final MenuBar.MenuItem newItem = file.addItem("New", null);
file.addItem("Open file...", menuCommand);
file.addSeparator();
newItem.addItem("File", menuCommand);
newItem.addItem("Folder", menuCommand);
newItem.addItem("Project...", menuCommand);
file.addItem("Close", menuCommand);
file.addItem("Close All", menuCommand);
file.addSeparator();
file.addItem("Save", menuCommand);
file.addItem("Save As...", menuCommand);
file.addItem("Save All", menuCommand);
final MenuBar.MenuItem edit = menubar.addItem("Edit", null);
edit.addItem("Undo", menuCommand);
edit.addItem("Redo", menuCommand).setEnabled(false);
edit.addSeparator();
edit.addItem("Cut", menuCommand);
edit.addItem("Copy", menuCommand);
edit.addItem("Paste", menuCommand);
edit.addSeparator();
final MenuBar.MenuItem find = edit.addItem("Find/Replace", menuCommand);
// Actions can be added inline as well, of course
find.addItem("Google Search", new Command() {
public void menuSelected(MenuItem selectedItem) {
getWindow().open(new ExternalResource("http://www.google.com"));
}
});
find.addSeparator();
find.addItem("Find/Replace...", menuCommand);
find.addItem("Find Next", menuCommand);
find.addItem("Find Previous", menuCommand);
final MenuBar.MenuItem view = menubar.addItem("View", null);
view.addItem("Show/Hide Status Bar", menuCommand);
view.addItem("Customize Toolbar...", menuCommand);
view.addSeparator();
view.addItem("Actual Size", menuCommand);
view.addItem("Zoom In", menuCommand);
view.addItem("Zoom Out", menuCommand);
addComponent(menubar);
}
private Command menuCommand = new Command() {
public void menuSelected(MenuItem selectedItem) {
getWindow().showNotification("Action " + selectedItem.getText());
}
};
it gets the error
javax.servlet.ServletException: java.lang.ClassCastException: com.example.menu.MenuApplication cannot be cast to com.vaadin.Application
com.vaadin.terminal.gwt.server.AbstractApplicationServlet.handleServiceException(AbstractApplicationServlet.java:966)
com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:523)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
java.lang.ClassCastException: com.example.menu.MenuApplication cannot be cast to com.vaadin.Application
com.vaadin.terminal.gwt.server.ApplicationServlet.getNewApplication(ApplicationServlet.java:82)
com.vaadin.terminal.gwt.server.AbstractApplicationServlet.createApplication(AbstractApplicationServlet.java:940)
com.vaadin.terminal.gwt.server.AbstractApplicationServlet.findApplicationInstance(AbstractApplicationServlet.java:768)
com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:431)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
i am using tomcat and eclipse for my development... can any one tell me y i cam getting this error