vaadin CalendarExample Context Menu


I am new in vaadin 7.1.9. I want to create a calendar component. I used the example code from vaadin book (CalendarExample-Context Menu).

the development environment: eclipse kapler
build managment: maven 2

the calendar is created. but when I want to add a new event by right mouse click I get the following error message:

Jan 9, 2014 10:38:08 AM com.vaadin.server.DefaultErrorHandler doDefault
com.vaadin.server.ServerRpcManager$RpcInvocationException: Unable to invoke method actionOnEmptyCell in com.vaadin.shared.ui.calendar.CalendarServerRpc
at com.vaadin.server.ServerRpcManager.applyInvocation(
at com.vaadin.server.ServerRpcManager.applyInvocation(
at com.vaadin.server.communication.ServerRpcHandler.handleBurst(
at com.vaadin.server.communication.ServerRpcHandler.handleRpc(
at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(
at com.vaadin.server.VaadinService.handleRequest(
at com.vaadin.server.VaadinServlet.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.apache.catalina.core.StandardWrapperValve.invoke(
at org.apache.catalina.core.StandardContextValve.invoke(
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.valves.ErrorReportValve.invoke(
at org.apache.catalina.valves.AccessLogValve.invoke(
at org.apache.catalina.core.StandardEngineValve.invoke(
at org.apache.catalina.connector.CoyoteAdapter.service(
at org.apache.coyote.http11.Http11Processor.process(
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(
at java.util.concurrent.ThreadPoolExecutor$
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at com.vaadin.server.ServerRpcManager.applyInvocation(
… 24 more
Caused by: java.lang.ClassCastException: com.vaadin.ui.Calendar$CalendarServerRpcImpl cannot be cast to com.vaadin.ui.Calendar
at com.vaadin.ui.Calendar$CalendarServerRpcImpl.actionOnEmptyCell(
… 29 more

public void handleAction(Action action, Object sender, Object target) {
// The sender is the Calendar object

			System.out.println("Sender Objekt: " + sender.getClass().getCanonicalName());

//here is the classCastExeption
Calendar calendar = (Calendar) sender;

			if (action == addEventAction) {
				// Check that the click was not done on an event
				if (target instanceof Date) {
					Date date = (Date) target;
					// Add an event from now to plus one hour
					GregorianCalendar start = new GregorianCalendar();
					GregorianCalendar end = new GregorianCalendar();
					end.add(java.util.Calendar.HOUR, 1);
					calendar.addEvent(new BasicEvent("Calendar study", "Learning how to use Vaadin Calendar", start.getTime(), end.getTime()));
				} else"No event to delete");
			} else if (action == deleteEventAction) {
				// Check if the action was clicked on top of an event
				if (target instanceof CalendarEvent) {
					CalendarEvent event = (CalendarEvent) target;
				} else"No event to delete");



can someone help me please

Hi all,

I’m supporting my colleague to solve this problem and I already had a look at his code snippet. Also, I checked his implementation against your vaadin calendar example ( As he posted the problem days ago the code crashed while casting a class at runtime.

My colleague got a phone call from someone of you today afternoon (Jan, 13th - around 11:55am) and I assume it was about this problem. Unfortunately he was not at his work place at that time.

We know that the example code is still under work, but may we ask you whether you have a fixing or not? We need an
appropriate calendar solution asap. We already tried to get in touch with your office today. Please, could your call us again or
get in touch with us by mail: In case you prefer a phone call from our side, then please just let us know the date and time.

We are looking forward to hearing from you again.

Thanks & best regards,

Based on a quick look at the stack trace and your method, it is clear that the sender is not the Calendar but a CalendarServerRpcImpl instance. This is confirmed by taking a look at Calendar$CalendarServerRpcImpl.actionOnEmptyCell(…). This is also the case when the action handler is called by actionOnEvent(…).

Unfortunately, the sender parameter value is not very useful in this case as the nested class CalendarServerRpcImpl is private. It would contain the information about the containing Calendar instance, but it is hard to get hold of for the previously mentioned reason. You might want to use separate handler instances for separate Calendars and keep track of the calendar there until the issue is resolved.

I created a ticket to give the calendar instance as the sender (

I have no information on who from our side might have been in contact with you, and I’m not aware of an active support contract. Do you have an open support ticket?

I deleted the line:

Calendar calendar = (Calendar) sender;

that works fine

the sender object is the same calander object in my class.

unnecessary casting

Hi Hesam
What do you mean that your sender object is the same calendar object ?
How did you solve this issue?

Hi Sina,

the Type of Sender Object is com.vaadin.ui.Calendar

I hope it helps you