2 Replies Latest reply on Feb 28, 2006 11:26 AM by Kabir Khan

    Overloaded constructor confusion

    Kabir Khan Master

      I am going through the "jca" and "rars" tests, and have run into some problems.

      The rars JBossMQUnitTestCase.xml reads:

       ...
       <bean name="GCF" class="org.jboss.mq.GenericConnectionFactory">
       ...
       </bean>
       ...
       <bean name="ConnectionFactory" class="org.jboss.mq.SpyConnectionFactory">
       <constructor>
       <parameter/></parameter>
       </constructor>
       </bean>
       ...
      


      When run, we get this error:
      844 ERROR [AbstractKernelController] Error installing to Instantiated: name=ConnectionFactory state=Described
      java.lang.IllegalArgumentException: Wrong arguments. new for target java.lang.reflect.Constructor expected=[java.util.Properties] actual=[org.jboss.mq.GenericConnectionFactory]
       at org.jboss.reflect.plugins.introspection.ReflectionUtils.handleErrors(ReflectionUtils.java:224)
       at org.jboss.reflect.plugins.introspection.ReflectionUtils.newInstance(ReflectionUtils.java:140)
       at org.jboss.reflect.plugins.introspection.ReflectConstructorInfoImpl.newInstance(ReflectConstructorInfoImpl.java:103)
      


      It is trying to use the SpyConnectionFactory taking a java.util.Properties as it's parameter while passing in a GenericConnectionFactory. It works fine if I explicitly make it use the other constructor.

       <bean name="ConnectionFactory" class="org.jboss.mq.SpyConnectionFactory">
       <constructor>
       <parameter class="org.jboss.mq.GenericConnectionFactory"><inject bean="GCF"/></parameter>
       </constructor>
       </bean>
      


      Shouldn't the mc be able to figure out which overloaded constructor to use from the type of the injected parameter?

      A similar issue exists for QueueConnectionFactory for the JMSUnitTestCase.