2 Replies Latest reply on Jul 14, 2009 12:25 AM by Arbi Sookazian

    Could not set field value by reflection

    Arbi Sookazian Master

      Seam 2.0.2


      SFSB:


      @Name("equipmentProcessing")
      @Stateful
      public class EquipmentProcessingAction implements EquipmentProcessingLocal {
      
         @DataModel private List equipmentProcessingList;
      
         ...
      
         @SuppressWarnings("unchecked")
           @Begin(join=true, flushMode=FlushModeType.MANUAL)
           public void search(){
                
                     
                int icomsSiteId = selectedListValueForSite.getCode();
                int customerStatusCode = selectedListValueForRecoveryType.getListValueId();
                
                
                int accountStatusListValueCode = selectedListValueForRecoveryStatus.getListValueId();
                String statusName = selectedListValueForRecoveryStatus.getListValue();
                
                Integer equipmentStatusId = (Integer)entityManager.createQuery("select eqStatus.equipmentStatusId "+
                                                                                                " from EquipmentStatus eqStatus "+
                                                                                                " where eqStatus.statusName = :statusName "+
                                                                                                " and eqStatus.accountStatusListValueCode = :accountStatusListValueCode")
                                                                                                .setParameter("statusName", statusName)
                                                                                                .setParameter("accountStatusListValueCode", accountStatusListValueCode)
                                                                                                .getSingleResult();
                     
                
                //temporarily hard-coding 'A' for customerStatusCode...
                equipmentProcessingList = entityManager.createNativeQuery("select AppSite.SiteName, "+
                            " er.AccountNumber, "+
                           " er.ServiceOccurance, "+
                           " er.ItemNumber, "+
                           " er.SerialNumber, "+
                            " eqType.ListValue "+
                           " from EquipmentRecoveryStatusChangeLog as erscl "+
                           " INNER JOIN EquipmentRecovery as er "+
                           " ON erscl.EquipmentRecoveryID =  er.EquipmentRecoveryID "+
                           " INNER JOIN ApplicationSite as AppSite "+
                           " ON AppSite.InternalSiteID = er.IcomsSiteID "+
                           " INNER JOIN RecoveredEquipmentManagement as rem "+
                           " ON AppSite.ApplicationSiteID = rem.ApplicationSiteID "+
                           " AND er.ItemNumber = rem.ICOMS_ITEM_NUMBER "+
                           " INNER JOIN (SELECT ListValue, ListValueID  FROM ListValue WHERE ListID = 4) as eqType "+
                           " ON rem.EquipmentType = eqType.ListValueID "+
                           " where erscl.IsCurrent = 1 "+
                           " AND erscl.EquipmentStatusID = :equipmentStatusId "+
                           " AND er.IcomsSiteID = :icomsSiteId "+
                           " AND er.CustomerStatusCode = :customerStatusCode ")
                           .setParameter("equipmentStatusId", equipmentStatusId)
                           .setParameter("icomsSiteId", icomsSiteId)
                           .setParameter("customerStatusCode", "A")
                           .getResultList();
                      
                if(equipmentProcessingList != null)
                     log.info("equipmentProcessingList.size() = "+ equipmentProcessingList.size());
           }
      }



      stack trace:


      15:04:52,656 ERROR [STDERR] ss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
           at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:206)
           at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:117)
           at $Proxy715.getSelectedListValueForSite(Unknown Source)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
           at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
           at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
           at org.jboss.seam.ejb.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:41)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
           at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
           at org.javassist.tmp.java.lang.Object_$$_javassist_7.getSelectedListValueForSite(Object_$$_javassist_7.java)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
           at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
           at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
           at org.jboss.el.parser.AstPropertySuffix.getValue(AstPropertySuffix.java:53)
           at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
           at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
           at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
           ... 82 more
      Caused by: java.lang.IllegalArgumentException: could not set field value: equipmentProcessing.equipmentProcessingList
           at org.jboss.seam.Component.setFieldValue(Component.java:1792)
           at org.jboss.seam.Component.access$600(Component.java:139)
           at org.jboss.seam.Component$BijectedField.set(Component.java:2630)
           at org.jboss.seam.Component.injectDataModelSelection(Component.java:1511)
           at org.jboss.seam.Component.injectDataModelSelections(Component.java:1481)
           at org.jboss.seam.Component.inject(Component.java:1420)
           at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:45)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.persistence.ManagedEntityIdentityInterceptor.aroundInvoke(ManagedEntityIdentityInterceptor.java:48)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.core.ConversationInterceptor.aroundInvoke(ConversationInterceptor.java:65)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:26)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:27)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
           at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
           at sun.reflect.GeneratedMethodAccessor1142.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
           at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
           at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
           ... 122 more
      Caused by: java.lang.IllegalArgumentException: Could not set field value by reflection: EquipmentProcessingAction.equipmentProcessingSelection on: com.cox.ers.session.EquipmentProcessingAction with value: class [Ljava.lang.Object;
           at org.jboss.seam.util.Reflections.set(Reflections.java:79)
           at org.jboss.seam.Component.setFieldValue(Component.java:1788)
           ... 156 more
      Caused by: java.lang.IllegalArgumentException
           at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
           at java.lang.reflect.Field.set(Field.java:656)
           at org.jboss.seam.util.Reflections.set(Reflections.java:64)
           ... 157 more



      Which field exactly is the problem here?  root cause (java.lang.IllegalArgumentException) is not specific enough...

        • 1. Re: Could not set field value by reflection
          Arbi Sookazian Master

          In the facelet, it's occurring here:


          javax.el.ELException: /EquipmentProcessing.xhtml @31,27 value="#{equipmentProcessing.selectedListValueForSite}": Error reading 'selectedListValueForSite' on type org.javassist.tmp.java.lang.Object_$$_javassist_7
          



          which is:


          <h:selectOneMenu id="selectedListValueForSiteId"
                     value="#{equipmentProcessing.selectedListValueForSite}"
                     required="true">



          not sure what is going on....

          • 2. Re: Could not set field value by reflection
            Arbi Sookazian Master

            Aha! figured it out.


            I tried changing my SFSB component to a JavaBean but I reproduced the stack trace.


            so it was this:


            @DataModel private List equipmentProcessingList;
                 
            @DataModelSelection private RecoveredEquipmentManagement equipmentProcessingSelection;



            when I commented the 2nd line, the dataTable rendered ok (i.e. no stack trace/exception).


            I would say better exception handling from the Seam code base is required in this scenario...