2 Replies Latest reply on Nov 10, 2010 4:54 AM by Gab Aldian

    Could not create Component, type argument not a class

    Gab Aldian Newbie

      I am posting this new Thread as a complement of my other question to target the problem from a different angle. I am trying to declare several instances of the same class, with one different attribute each time. Something like this:


      <component name="car" class="dao.GenericEntityHome">
                <property name="classtype">
                     <value>entity.Car</value>
                </property>
           </component> 
      
      <component name="bus" class="dao.GenericEntityHome">
                <property name="classtype">
                     <value>entity.Bus</value>
                </property>
           </component> 
           
      <component name="moto" class="dao.GenericEntityHome">
                <property name="classtype">
                     <value>entity.Moto</value>
                </property>
           </component> 
           
      <component name="tramway" class="dao.GenericEntityHome">
                <property name="classtype">
                     <value>entity.Tramway</value>
                </property>
           </component> 
           
      
      public class GenericEntityHome extends EntityHome {
           
           private static final Log log = LogFactory.getLog(GenericEntityHome.class);
           private int maximumId = -1;
           private Class<? extends IEntity> classtype =null;
           private String className = null;
           
           
           /**
            * @param classtype the classtype to set
            */
           private void setClasstype(Class<? extends IEntity> classtype) {
                this.classtype = classtype;
           }
           
           @SuppressWarnings("unchecked")
           public void setClasstype(String classtype) {
                try {
                     this.className = new String(classtype);
                     setClasstype((Class<? extends IEntity>) Class.forName(classtype));
                } catch (ClassNotFoundException e) {
                     e.printStackTrace();
                }
           }
      }



      Of course, the class GenericEntityHome contains also some more code.
      I took inspiration from the documentation where we can found for example:


      <component name="org.jboss.seam.core.manager">
          <property name="conversationTimeout">60000</property>
      </component>



      But I have an exception when trying to run, and I have tried a lot of things without being able of finding out the problem.



      java.lang.RuntimeException: Could not create Component: car
      Caused by: java.lang.IllegalArgumentException: type argument not a class



      My one and only question: why do I have this exception? I have tried a lot of possibilities and am still stuck with it.


      Thank you very much for your help.