5 Replies Latest reply on Nov 15, 2006 10:45 PM by Anne Forumer

    ClassCastException with ArrayList when implementing SelectOn

    Anne Forumer Newbie

      JBoss-4.0.4.CR2 and Seam 1.0.1.GA

      I am trying to implement my first SelectOneMenu.

      I'd appreciate any help in figuring out why I am getting this ClassCastException. This is happening in the framework soon after method is completed.

      I am using a ModelConverter which is registered in faces-config.xml. The exception happens immediately after the "allModelsM" method.

      xhtml snippet is:

       <h:selectOneMenu id="modelSelect" value="#{fleetManagerAdmin.selectedModel}"
       converter="ModelConverter">
       <f:selectItems value="#{allModelsSI}" />
       </h:selectOneMenu>
      
      


      relevant parts of Backing bean, a StatefulSessionBean are:

      @Stateful
      @Scope(ScopeType.SESSION)
      @Name("fleetManagerAdmin")
      
      public class FleetManagerAdminBean implements FleetManagerAdmin
      .
      .
       @In(required=false)
       public Model selectedModel;
       public Model getSelectedModel(){return selectedModel;}
       public void setSelectedModel(Model item){this.selectedModel = item;}
      
       @Out(required=false)
       private SelectItem[] allModelsSI;
       public SelectItem[] getAllModelsSI(){return allModelsSI;}
       public void setAllModelsSI(SelectItem[] allModelsSI){this.allModelsSI = allModelsSI;}
      .
      .
      .
      
       @Factory("allModelsSI")
       public void allModelsM()
       {
       log.debug(">>>allModelsM..");
       allModels = em.createNamedQuery("findAllModels").getResultList();
       SelectItem[] allModelsSI= new SelectItem[allModels.size()];
       int i=0;
       for(Model m: allModels)
       {
       log.debug("allModelsM() model="+m);
       allModelsSI[i++] = new SelectItem(m);
       }
       log.debug("<<<allModelsM()");
       }
      .
      .
      .
      
      


      Beginning part of stack-trace (quite long) is:

      19:01:48,802 DEBUG [FleetManagerAdminBean] >>>allModelsM..
      19:01:48,802 DEBUG [FleetManagerAdminBean] >>>allModelsM..
      19:01:48,812 DEBUG [FleetManagerAdminBean] allModelsM() model=777-200
      19:01:48,812 DEBUG [FleetManagerAdminBean] allModelsM() model=777-200
      19:01:48,822 DEBUG [FleetManagerAdminBean] allModelsM() model=777-200ER
      19:01:48,822 DEBUG [FleetManagerAdminBean] allModelsM() model=777-200ER
      19:01:48,822 DEBUG [FleetManagerAdminBean] allModelsM() model=777-200LR
      19:01:48,822 DEBUG [FleetManagerAdminBean] allModelsM() model=777-200LR
      19:01:48,822 DEBUG [FleetManagerAdminBean] allModelsM() model=777-300
      19:01:48,822 DEBUG [FleetManagerAdminBean] allModelsM() model=777-300
      19:01:48,832 DEBUG [FleetManagerAdminBean] allModelsM() model=777-300ER
      19:01:48,832 DEBUG [FleetManagerAdminBean] allModelsM() model=777-300ER
      19:01:48,832 DEBUG [FleetManagerAdminBean] <<<allModelsM()
      19:01:48,832 DEBUG [FleetManagerAdminBean] <<<allModelsM()
      19:01:48,832 DEBUG [RemoveInterceptor] Stateful component was removed: fleetManagerAdmin
      19:01:48,842 ERROR [STDERR] javax.ejb.EJBException: java.lang.ClassCastException: java.util.ArrayList
      19:01:48,842 ERROR [STDERR] at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
      19:01:48,842 ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
      19:01:48,842 ERROR [STDERR] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:192)
      19:01:48,842 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      19:01:48,842 ERROR [STDERR] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
      19:01:48,842 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      19:01:48,842 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:81)
      19:01:48,842 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      19:01:48,842 ERROR [STDERR] at org.jboss.aspects.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:167)
      19:01:48,842 ERROR [STDERR] at org.jboss.ejb3.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:100)
      19:01:48,842 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      19:01:48,842 ERROR [STDERR] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
      19:01:48,842 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      19:01:48,842 ERROR [STDERR] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
      19:01:48,842 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      19:01:48,842 ERROR [STDERR] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
      19:01:48,842 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      19:01:48,842 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:188)
      19:01:48,842 ERROR [STDERR] at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:98)
      19:01:48,842 ERROR [STDERR] at $Proxy186.allModelsM(Unknown Source)
      19:01:48,842 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      19:01:48,842 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      19:01:48,842 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      19:01:48,842 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
      19:01:48,842 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
      19:01:48,842 ERROR [STDERR] at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:32)
      19:01:48,842 ERROR [STDERR] at org.jboss.seam.Component.callComponentMethod(Component.java:1334)
      19:01:48,842 ERROR [STDERR] at org.jboss.seam.Component.getInstanceFromFactory(Component.java:1293)
      19:01:48,842 ERROR [STDERR] at org.jboss.seam.Component.getInstance(Component.java:1260)
      19:01:48,842 ERROR [STDERR] at org.jboss.seam.Component.getInstance(Component.java:1246)
      19:01:48,842 ERROR [STDERR] at org.jboss.seam.jsf.SeamVariableResolver.resolveVariable(SeamVariableResolver.java:44)
      19:01:48,842 ERROR [STDERR] at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:134)
      19:01:48,842 ERROR [STDERR] at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:65)
      19:01:48,842 ERROR [STDERR] at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
      19:01:48,842 ERROR [STDERR] at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
      19:01:48,842 ERROR [STDERR] at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:56)
      19:01:48,842 ERROR [STDERR] at javax.faces.component.UISelectItems.getValue(UISelectItems.java:55)
      19:01:48,842 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      19:01:48,842 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      19:01:48,842 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      19:01:48,842 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
      19:01:48,842 ERROR [STDERR] at com.sun.facelets.util.DevTools.writeAttributes(DevTools.java:240)
      19:01:48,842 ERROR [STDERR] at com.sun.facelets.util.DevTools.writeStart(DevTools.java:277)
      19:01:48,842 ERROR [STDERR] at com.sun.facelets.util.DevTools.writeComponent(DevTools.java:189)
      19:01:48,842 ERROR [STDERR] at com.sun.facelets.util.DevTools.writeComponent(DevTools.java:207)
      19:01:48,842 ERROR [STDERR] at com.sun.facelets.util.DevTools.writeComponent(DevTools.java:207)
      19:01:48,842 ERROR [STDERR] at com.sun.facelets.util.DevTools.writeComponent(DevTools.java:207)
      19:01:48,842 ERROR [STDERR] at com.sun.facelets.util.DevTools.debugHtml(DevTools.java:133)
      19:01:48,842 ERROR [STDERR] at com.sun.facelets.tag.ui.UIDebug.writeDebugOutput(UIDebug.java:78)
      19:01:48,842 ERROR [STDERR] at com.sun.facelets.tag.ui.UIDebug.encodeBegin(UIDebug.java:67)
      19:01:48,842 ERROR [STDERR] at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:232)
      19:01:48,842 ERROR [STDERR] at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
      19:01:48,842 ERROR [STDERR] at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:554)
      19:01:48,842 ERROR [STDERR] at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352)
      19:01:48,842 ERROR [STDERR] at javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
      19:01:48,842 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      19:01:48,842 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      19:01:48,842 ERROR [STDERR] at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
      19:01:48,842 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      19:01:48,842 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      19:01:48,842 ERROR [STDERR] at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:30)
      19:01:48,842 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      19:01:48,842 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      19:01:48,842 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      19:01:48,842 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      19:01:48,842 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      19:01:48,842 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      19:01:48,842 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      19:01:48,842 ERROR [STDERR] at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:54)
      19:01:48,842 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:174)
      19:01:48,842 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      19:01:48,842 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      19:01:48,842 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      19:01:48,842 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      19:01:48,842 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      19:01:48,842 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
      19:01:48,842 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
      19:01:48,842 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      19:01:48,842 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      19:01:48,842 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
      19:01:48,842 ERROR [STDERR] Caused by: java.lang.ClassCastException: java.util.ArrayList
      19:01:48,842 ERROR [STDERR] at org.jboss.seam.databinding.DataModelBinder.isDirty(DataModelBinder.java:19)
      19:01:48,842 ERROR [STDERR] at org.jboss.seam.Component.outjectDataModelList(Component.java:973)
      19:01:48,842 ERROR [STDERR] at org.jboss.seam.Component.outjectDataModels(Component.java:937)
      19:01:48,842 ERROR [STDERR] at org.jboss.seam.Component.outject(Component.java:857)
      19:01:48,842 ERROR [STDERR] at org.jboss.seam.interceptors.BijectionInterceptor.bijectTargetComponent(BijectionInterceptor.java:41)
      19:01:48,842 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      19:01:48,842 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      19:01:48,842 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      19:01:48,842 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
      19:01:48,842 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
      19:01:48,842 ERROR [STDERR] at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
      19:01:48,842 ERROR [STDERR] at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
      19:01:48,842 ERROR [STDERR] at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(ConversationInterceptor.java:82)
      19:01:48,842 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      19:01:48,842 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      19:01:48,842 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      19:01:48,842 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
      19:01:48,842 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
      19:01:48,842 ERROR [STDERR] at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
      19:01:48,842 ERROR [STDERR] at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
      19:01:48,842 ERROR [STDERR] at org.jboss.seam.interceptors.BusinessProcessInterceptor.manageBusinessProcessContext(BusinessProcessInterceptor.java:60)
      19:01:48,842 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      19:01:48,842 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      19:01:48,842 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      19:01:48,852 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
      19:01:48,852 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
      19:01:48,852 ERROR [STDERR] at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
      19:01:48,852 ERROR [STDERR] at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
      19:01:48,852 ERROR [STDERR] at org.jboss.seam.interceptors.RemoveInterceptor.removeIfNecessary(RemoveInterceptor.java:39)
      19:01:48,852 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      19:01:48,852 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      19:01:48,852 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      19:01:48,852 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
      19:01:48,852 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:13)
      19:01:48,852 ERROR [STDERR] at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Interceptor.java:90)
      19:01:48,852 ERROR [STDERR] at org.jboss.seam.interceptors.SeamInvocationContext.proceed(SeamInvocationContext.java:60)
      19:01:48,852 ERROR [STDERR] at org.jboss.seam.ejb.SeamInterceptor.aroundInvokeInContexts(SeamInterceptor.java:73)
      19:01:48,852 ERROR [STDERR] at org.jboss.seam.ejb.SeamInterceptor.aroundInvoke(SeamInterceptor.java:45)
      19:01:48,852 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      19:01:48,852 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      19:01:48,852 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      19:01:48,852 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
      19:01:48,852 ERROR [STDERR] at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
      19:01:48,852 ERROR [STDERR] at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
      19:01:48,852 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      19:01:48,852 ERROR [STDERR] at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
      19:01:48,852 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      19:01:48,852 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
      19:01:48,852 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      19:01:48,852 ERROR [STDERR] at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
      19:01:48,852 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      19:01:48,852 ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
      19:01:48,852 ERROR [STDERR] ... 78 more
      19:01:48,852 DEBUG [SeamVariableResolver] resolving name: msgs
      19:01:48,852 DEBUG [Contexts] found in event context: msgs
      19:01:48,852 DEBUG [SeamVariableResolver] resolved name to seam component
      19:01:48,852 DEBUG [SeamVariableResolver] resolving name: allCids
      19:01:48,852 DEBUG [Component] instantiating Seam component: fleetManagerAdmin
      19:01:48,852 DEBUG [Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.j
      np.interfaces}
      19:01:48,862 DEBUG [Contexts] found in conversation context: facesMessages
      19:01:48,862 DEBUG [Component] selected row: null
      19:01:48,862 DEBUG [RemoveInterceptor] Stateful component was removed: fleetManagerAdmin
      19:01:48,862 ERROR [STDERR] javax.ejb.EJBException: java.lang.ClassCastException: java.util.ArrayList
      19:01:48,862 ERROR [STDERR] at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)