ComboBox ValueChangeListener ClassCastException Exception

I have the following code:
(the code is taken from Vaadin combobox demo example. I just moved the event listener from the combobox class to the main application - VaadinresultentryApplication)

package com.example.vaadinresultentry;

[u]
[b]
import com.vaadin.data.Property.ValueChangeListener;
[/b]
[/u]
import com.vaadin.ui.AbstractSelect.Filtering;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.VerticalLayout;

@SuppressWarnings("serial")
public class ComboBoxOU extends VerticalLayout {

	private static final String[] OU = new String[]
 {
			"String1", "String2", "bla bla bla" };

	public ComboBoxOU(VaadinresultentryApplication app) {
		setMargin(true, false, false, false); // for looks: more 'air'

		// Create & set input prompt
		ComboBox l = new ComboBox();
		l.setInputPrompt("Please select a work center");
		l.setCaption("Work center");

		// configure & load content
		l.setFilteringMode(Filtering.FILTERINGMODE_OFF);
		l.setImmediate(true);
		[u]
[b]
l.addListener((ValueChangeListener) app);
[/b]
[/u]
		for (int i = 0; i < OU.length; i++) {
			l.addItem(OU[i]
);
		}

		// add to the layout
		addComponent(l);
	}
}

that throws the following exception

GRAVE: Servlet.service() for servlet [Vaadinresultentry Application]
in context with path
[/VaadinResultEntry] threw exception [java.lang.Cl
assCastException: com.example.vaadinresultentry.VaadinresultentryApplication cannot be cast to com.vaadin.data.Property$ValueChangeListener]
with root cause


java.lang.ClassCastException: com.example.vaadinresultentry.VaadinresultentryApplication cannot be cast to com.vaadin.data.Property$ValueCha
ngeListener


at com.example.vaadinresultentry.ComboBoxOU.(ComboBoxOU.java:301)
at com.example.vaadinresultentry.TabSheetFilter.createFilterVerticalLayout(TabSheetFilter.java:28)
at com.example.vaadinresultentry.TabSheetFilter.(TabSheetFilter.java:17)
at com.example.vaadinresultentry.VaadinresultentryApplication.buildMainLayout(VaadinresultentryApplication.java:33)
at com.example.vaadinresultentry.VaadinresultentryApplication.init(VaadinresultentryApplication.java:25)
at com.vaadin.Application.start(Application.java:554)
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.startApplication(AbstractApplicationServlet.java:1202)
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:484)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:399)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:317)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:204)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:182)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:311)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Can you help me please finding out the problem and solving it?

Thanks,
Francesco

Any help?

The problem is that your application (VaadinresultentryApplication) doesn’t implement the ValueChangeListener interface. You have to let the application class to implement the interface:

public class VaadinresultentryApplication implements ValueChangeListener {

...

public void valueChange(ValueChangeEvent event) {

}

...
}