SimpleAddressBook and Jetty Standalone


I hope this hasn’t been discussed already as I used the search and all that helped did unfortunately not solve my problem.

My premise: I want to run a Vaadin app through a standalone managed Jetty. I tested the Jetty in Eclipse, everything seems to work fine. Now, I referred to this
and this
and everything looks identical with me. But still I run into the problem, that as soon as I want to access SimpleAddressBook I get the following error:

Problem accessing /SimpleAddressBook. Reason:

SimpleAddressBook cannot be cast to com.vaadin.Application

Caused by:

java.lang.ClassCastException: SimpleAddressBook cannot be cast to com.vaadin.Application
at com.vaadin.terminal.gwt.server.ApplicationServlet.getNewApplication(
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.createApplication(
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.findApplicationInstance(
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(
at javax.servlet.http.HttpServlet.service(
at org.eclipse.jetty.servlet.ServletHolder.handle(
at org.eclipse.jetty.servlet.ServletHandler.doHandle(
at org.eclipse.jetty.server.handler.ScopedHandler.handle(
at org.eclipse.jetty.server.session.SessionHandler.handle(
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(
at org.eclipse.jetty.servlet.ServletHandler.doScope(
at org.eclipse.jetty.server.handler.ContextHandler.doScope(
at org.eclipse.jetty.server.handler.ScopedHandler.handle(
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
at org.eclipse.jetty.server.Server.handle(
at org.eclipse.jetty.server.HttpConnection.handleRequest(
at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(
at org.eclipse.jetty.http.HttpParser.parseNext(
at org.eclipse.jetty.http.HttpParser.parseAvailable(
at org.eclipse.jetty.server.HttpConnection.handle(
at org.eclipse.jetty.util.thread.QueuedThreadPool$
at Source)

The source of SimpleAddressBook is a complete copy of, the SVN, without any changes made to it. Still I get this error. Everything seems to be fine:

import com.vaadin.Application;

public class SimpleAddressBook extends Application {

I hope anybody can help me with this problem. Thanks already in advance.


This sounds very much like a classpath issue. If the application and the Vaadin JAR being used by Jetty have been loaded with different (and unrelated) classloaders, they might see two “different” com.vaadin.Application classes.

Do you have e.g. a Vaadin JAR in the WebContent directory and another one explicitly referenced from the classpath used by Jetty?


I had the same idea but I did not find a consistency problem (or at least I do not anymore where to look). I created the project like suggested through the tutorial (Eclipse → Dynamic Web Project). Vaadin was downloaded and added automatically to the Web App Libraries as I can see it now. Nothing more was added by me to the project as libraries.

So, the main origin point was with the Dynamic Web Project and just the two classes of the SimpleServer and SimpleAddressBook copied. I am actually not sure how Eclipse handles this, but as the Build Path seem to be configured correctly, I hoped this it.

I am open for other suggestions or ways I maybe restart the project creation.

Hi again

OK, I did some tests now. What throws him out of line is the following


as it normally can work (as directory) and should, if probably nothing else requires some dynamic loading I could think.
If I deploy the web application and set the war


it works (another thing was that I forgot the vaadin package but that is now all included). Deployed everything works. Dynamic it does not.

If this helps maybe, I really would like to be able to make it through dynamics and not deployed all the time. This should work somehow, maybe just a small Eclipse setting…

Its me again and again ^^’

Another think I now tested and found out:
As mentioned I created a Dynamic Web Project through my eclipse3.5. Vaadin downloaded two GWT and a Vaadin lib. The GWT libs were included as external jars whereas the Vaadin lib was added to the WEB-INF/lin directory and included from there as Eclipse Web App Lib.
When I started the Jetty with WebContent (as classically created) as war it gave me that error. Deployed as .war file, no error.

Now, I added all libs, also vaadin lib, as external jars and/or user libraries in eclipse. Start the server, folder WebContent set, voilà it works. This may not be the solution to use or better said, the one aspired, but it is easy, no big change and does work for now. But nevertheless it would be interesting to rifle through the process to see were something goes wrong.


Classloader issues stated here are most likely because classloader is not set properly. Below code fixes this.

Here’s latest launcher file that should work out of the box with any Eclipse Galileo distributions (Java, Classic or JEE). No other plug-ins are required. It works with any IDE if you add Jetty JAR to your classpath. Hot code replace is almost immediate and works 100% reliably.

Important: remove all other Servlet Containers from your classpath, e.g. Apache Tomcat v6.0.

package com.example.launch;

import org.mortbay.jetty.Server;
import org.mortbay.jetty.webapp.WebAppContext;

public class Launcher {

	private static String contextPath = "/";
	private static String resourceBase = "WebContent";
	private static int httpPort = 8888;

	public static void main(String[] args) throws Exception {
		Server server = new Server(httpPort);
		WebAppContext webapp = new WebAppContext();
		System.out.println("Started Jetty " + Server.getVersion()
				+ ", go to http://localhost:" + httpPort + contextPath);


Hi, Jani. I’m a newbie in Vaadin. I can’t starting me application ( without HelloWord )) ).

I have a questions - all programs must extends com.vaadin.Aplication ?

I extends of com.vaadin.ui.Link - and got error:

java.lang.ClassCastException: com.example.myproject.MyprojectApplication cannot be cast to com.vaadin.Application

I’m add your class - Launcher to my package nearly my class - MyprojectApplication and delete Apache Tomcat v6.0 from classpath, but error still (((.

project structure

Please, help me.

Dani, yes, your application entry point must extend Application class. You can check the micro “HelloWorld” example source