1 Reply Latest reply on Feb 11, 2008 4:52 PM by Pete Muir

    Reflections uses wrong argument causing IllegalArgumentExcep

    Peter Boevink Newbie

      Hi,

      I'm trying to use an abstract class for some stateful beans that use a lot of similair functionality.
      But I'm having a lot of trouble using in-/outjections in combination with reflection.

      My abstract class:

      package common.selectableMap;
      
      //imports....
      
      @Scope(ScopeType.CONVERSATION)
      public abstract class AbstractMap
      {
      
       @Logger protected Log log;
       @In FacesMessages facesMessages;
       @In(create=true) protected Map<String, String> messages;
       @PersistenceContext (type=PersistenceContextType.EXTENDED)
       private EntityManager em;
      
       protected EntityQuery resultList;
       protected Map<Serializable, Boolean> checkedEntities;
      
       @Destroy @Remove
       public abstract void destroy();
      
       @Begin(join=true)
       public void begin()
       {
       log.info("abstractMap begin: " + getClass().getName());
       if (checkedEntities == null)
       {
       checkedEntities = new HashMap<Serializable, Boolean>();
       }
       }
      }
      
      

      The 'resultList' and 'checkedEntities' attributes are reflected by the subclass and will be in-/outjected by the subclass.

      My subclass:
      package common.selectableMap;
      
      // imports....
      
      @Stateful
      @Name("userMap")
      public class UserMap extends AbstractMap implements MapManager
      {
      
       @Override
       @Destroy @Remove
       public void destroy() {
       }
      
       @Out (scope=ScopeType.CONVERSATION, value="checkUsers")
       public Map<Serializable, Boolean> getCheckedEntities() {
       return checkedEntities;
       }
      
       public void setCheckedEntities(Map<Serializable, Boolean> checkedEntities) {
       this.checkedEntities = checkedEntities;
       }
      
       @In (required=false, value="resultList", scope=ScopeType.CONVERSATION)
       public EntityQuery getResultList() {
       return resultList;
       }
      
       public void setResultList(Object resultList) {
       }
      }
      
      


      This however causes an exception when using them:
      Caused by: java.lang.IllegalArgumentException: Could not invoke method by reflection: UserMap.getResultList() with parameters: (null) on: nl.wkm.orionglobe.web.entity.common.selectableMap.UserMap
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:31)
       at org.jboss.seam.Component.setPropertyValue(Component.java:1765)
       ... 119 more
      Caused by: java.lang.IllegalArgumentException: wrong number of arguments
       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)
       ... 120 more
      


      Why does the UserMap.getResultList() get called with a 'null' parameter?
      (It realy is, as I've checked while debugging)

      It should not use a parameter at all!