AnsweredAssumed Answered

ClassCastException when casting process variables

Question asked by mskaesz on Dec 22, 2010
Latest reply on Dec 29, 2010 by frederikheremans1
Hey guys,

I'm getting ClassCastExceptions when trying to cast process variables into my own variables:


public class PersistBookingDelegate implements JavaDelegate {

   private BookingDAOLocal bookingDAOLocal;

   @Override
   public void execute(DelegateExecution e) throws Exception {
      try {
         InitialContext ctx = new InitialContext();
         bookingDAOLocal = (BookingDAOLocal) ctx.lookup("Advertising_v1.0/BookingDAO/local");
      } catch (NamingException ex) {
         ex.printStackTrace();
      }

      BookingDTO b = (BookingDTO) e.getVariable("bookingDTO");

      EBooking booking = bookingDAOLocal.makePersistent(BookingHelper.mapDTOToEntity(b));
   }
}



10:03:18,246 ERROR [STDERR] java.lang.ClassCastException: de.advertising.backend.dto.BookingDTO cannot be cast to de.advertising.backend.dto.BookingDTO
10:03:18,246 ERROR [STDERR]    at de.advertising.backend.delegates.PersistBookingDelegate.execute(PersistBookingDelegate.java:42)
10:03:18,246 ERROR [STDERR]    at org.activiti.engine.impl.bpmn.ClassDelegate.execute(ClassDelegate.java:96)
10:03:18,246 ERROR [STDERR]    at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:40)
10:03:18,246 ERROR [STDERR]    at org.activiti.engine.impl.pvm.runtime.ExecutionImpl.performOperation(ExecutionImpl.java:521)
10:03:18,246 ERROR [STDERR]    at org.activiti.engine.impl.pvm.runtime.ExecutionImpl.take(ExecutionImpl.java:387)
10:03:18,246 ERROR [STDERR]    at org.activiti.engine.impl.bpmn.BpmnActivityBehavior.performOutgoingBehavior(BpmnActivityBehavior.java:86)
10:03:18,246 ERROR [STDERR]    at org.activiti.engine.impl.bpmn.BpmnActivityBehavior.performDefaultOutgoingBehavior(BpmnActivityBehavior.java:47)
10:03:18,246 ERROR [STDERR]    at org.activiti.engine.impl.bpmn.AbstractBpmnActivity.leave(AbstractBpmnActivity.java:44)
10:03:18,246 ERROR [STDERR]    at org.activiti.engine.impl.bpmn.UserTaskActivity.signal(UserTaskActivity.java:62)
10:03:18,246 ERROR [STDERR]    at org.activiti.engine.impl.pvm.runtime.ExecutionImpl.signal(ExecutionImpl.java:371)
10:03:18,246 ERROR [STDERR]    at org.activiti.engine.impl.task.TaskEntity.complete(TaskEntity.java:172)
10:03:18,246 ERROR [STDERR]    at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:52)
10:03:18,246 ERROR [STDERR]    at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:27)
10:03:18,247 ERROR [STDERR]    at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:22)
10:03:18,247 ERROR [STDERR]    at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:37)
10:03:18,247 ERROR [STDERR]    at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
10:03:18,247 ERROR [STDERR]    at org.activiti.engine.impl.TaskServiceImpl.complete(TaskServiceImpl.java:100)
10:03:18,247 ERROR [STDERR]    at de.advertising.frontend.windows.CheckBookingWindow$1.buttonClick(CheckBookingWindow.java:59)
10:03:18,247 ERROR [STDERR]    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
10:03:18,247 ERROR [STDERR]    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
10:03:18,247 ERROR [STDERR]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
10:03:18,247 ERROR [STDERR]    at java.lang.reflect.Method.invoke(Method.java:597)
10:03:18,247 ERROR [STDERR]    at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:487)
10:03:18,247 ERROR [STDERR]    at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
10:03:18,247 ERROR [STDERR]    at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1154)
10:03:18,247 ERROR [STDERR]    at com.vaadin.ui.Button.fireClick(Button.java:371)
10:03:18,247 ERROR [STDERR]    at com.vaadin.ui.Button.changeVariables(Button.java:193)
10:03:18,247 ERROR [STDERR]    at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1094)
10:03:18,247 ERROR [STDERR]    at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:590)
10:03:18,247 ERROR [STDERR]    at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:266)
10:03:18,247 ERROR [STDERR]    at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:476)
10:03:18,247 ERROR [STDERR]    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
10:03:18,247 ERROR [STDERR]    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
10:03:18,247 ERROR [STDERR]    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
10:03:18,248 ERROR [STDERR]    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
10:03:18,248 ERROR [STDERR]    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
10:03:18,248 ERROR [STDERR]    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
10:03:18,248 ERROR [STDERR]    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
10:03:18,248 ERROR [STDERR]    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
10:03:18,248 ERROR [STDERR]    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
10:03:18,248 ERROR [STDERR]    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
10:03:18,248 ERROR [STDERR]    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
10:03:18,248 ERROR [STDERR]    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
10:03:18,248 ERROR [STDERR]    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
10:03:18,248 ERROR [STDERR]    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
10:03:18,248 ERROR [STDERR]    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
10:03:18,248 ERROR [STDERR]    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
10:03:18,248 ERROR [STDERR]    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
10:03:18,248 ERROR [STDERR]    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
10:03:18,248 ERROR [STDERR]    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
10:03:18,248 ERROR [STDERR]    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
10:03:18,248 ERROR [STDERR]    at java.lang.Thread.run(Thread.java:662)
10:03:18,251 ERROR [STDERR] com.vaadin.event.ListenerMethod$MethodException
Cause: java.lang.ClassCastException: de.advertising.backend.dto.BookingDTO cannot be cast to de.advertising.backend.dto.BookingDTO
10:03:18,251 ERROR [STDERR]    at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:507)
10:03:18,252 ERROR [STDERR]    at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
10:03:18,252 ERROR [STDERR]    at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1154)
10:03:18,252 ERROR [STDERR]    at com.vaadin.ui.Button.fireClick(Button.java:371)
10:03:18,252 ERROR [STDERR]    at com.vaadin.ui.Button.changeVariables(Button.java:193)
10:03:18,252 ERROR [STDERR]    at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1094)
10:03:18,252 ERROR [STDERR]    at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:590)
10:03:18,252 ERROR [STDERR]    at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:266)
10:03:18,252 ERROR [STDERR]    at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:476)
10:03:18,252 ERROR [STDERR]    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
10:03:18,252 ERROR [STDERR]    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
10:03:18,252 ERROR [STDERR]    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
10:03:18,252 ERROR [STDERR]    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
10:03:18,252 ERROR [STDERR]    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
10:03:18,252 ERROR [STDERR]    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
10:03:18,252 ERROR [STDERR]    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
10:03:18,252 ERROR [STDERR]    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
10:03:18,252 ERROR [STDERR]    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
10:03:18,252 ERROR [STDERR]    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
10:03:18,252 ERROR [STDERR]    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
10:03:18,252 ERROR [STDERR]    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
10:03:18,252 ERROR [STDERR]    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
10:03:18,253 ERROR [STDERR]    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
10:03:18,253 ERROR [STDERR]    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
10:03:18,253 ERROR [STDERR]    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
10:03:18,253 ERROR [STDERR]    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
10:03:18,253 ERROR [STDERR]    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
10:03:18,253 ERROR [STDERR]    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
10:03:18,253 ERROR [STDERR]    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
10:03:18,253 ERROR [STDERR]    at java.lang.Thread.run(Thread.java:662)
10:03:18,253 ERROR [STDERR] Caused by: java.lang.ClassCastException: de.advertising.backend.dto.BookingDTO cannot be cast to de.advertising.backend.dto.BookingDTO
10:03:18,253 ERROR [STDERR]    at de.advertising.backend.delegates.PersistBookingDelegate.execute(PersistBookingDelegate.java:42)
10:03:18,253 ERROR [STDERR]    at org.activiti.engine.impl.bpmn.ClassDelegate.execute(ClassDelegate.java:96)
10:03:18,253 ERROR [STDERR]    at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:40)
10:03:18,253 ERROR [STDERR]    at org.activiti.engine.impl.pvm.runtime.ExecutionImpl.performOperation(ExecutionImpl.java:521)
10:03:18,253 ERROR [STDERR]    at org.activiti.engine.impl.pvm.runtime.ExecutionImpl.take(ExecutionImpl.java:387)
10:03:18,253 ERROR [STDERR]    at org.activiti.engine.impl.bpmn.BpmnActivityBehavior.performOutgoingBehavior(BpmnActivityBehavior.java:86)
10:03:18,253 ERROR [STDERR]    at org.activiti.engine.impl.bpmn.BpmnActivityBehavior.performDefaultOutgoingBehavior(BpmnActivityBehavior.java:47)
10:03:18,253 ERROR [STDERR]    at org.activiti.engine.impl.bpmn.AbstractBpmnActivity.leave(AbstractBpmnActivity.java:44)
10:03:18,253 ERROR [STDERR]    at org.activiti.engine.impl.bpmn.UserTaskActivity.signal(UserTaskActivity.java:62)
10:03:18,253 ERROR [STDERR]    at org.activiti.engine.impl.pvm.runtime.ExecutionImpl.signal(ExecutionImpl.java:371)
10:03:18,253 ERROR [STDERR]    at org.activiti.engine.impl.task.TaskEntity.complete(TaskEntity.java:172)
10:03:18,254 ERROR [STDERR]    at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:52)
10:03:18,254 ERROR [STDERR]    at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:27)
10:03:18,254 ERROR [STDERR]    at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:22)
10:03:18,254 ERROR [STDERR]    at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:37)
10:03:18,254 ERROR [STDERR]    at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
10:03:18,254 ERROR [STDERR]    at org.activiti.engine.impl.TaskServiceImpl.complete(TaskServiceImpl.java:100)
10:03:18,254 ERROR [STDERR]    at de.advertising.frontend.windows.CheckBookingWindow$1.buttonClick(CheckBookingWindow.java:59)
10:03:18,254 ERROR [STDERR]    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
10:03:18,254 ERROR [STDERR]    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
10:03:18,254 ERROR [STDERR]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
10:03:18,254 ERROR [STDERR]    at java.lang.reflect.Method.invoke(Method.java:597)
10:03:18,254 ERROR [STDERR]    at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:487)
10:03:18,254 ERROR [STDERR]    … 29 more

The BookingDTO is in the same jar together with all Delegates, located next to the activiti-engine.jar. The engine is located in my server/default/lib folder (JBoss 5).

Any ideas?

Cheers,
Marc

Outcomes