Aries
  1. Aries
  2. ARIES-843

Bean can not be created if constructor argument use generics

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.3
    • Fix Version/s: blueprint-core-1.0.1
    • Component/s: Blueprint
    • Labels:
      None

      Description

      If a bean has a constructor argument which use generics, the injection fails with "org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to find a matching constructor".

      Example:
      package example;
      public interface Example<A> {}

      public class ExampleImpl implements Example<String> {}

      public class Service {
      private Example<String> example;
      public Service(Example<String> example)

      { this.example = example; }

      }

      <bean id="exampleBean" class="example.ExampleImpl"/>

      <bean id="serviceBean" class="example.Service">
      <argument ref="exampleBean"/>
      </bean>

      Changing the constructor of Service to "public Service(Example example)" make it work, but it would be better to have it inject correctly with the generics intact.

        Issue Links

          Activity

          Tomas Forsman created issue -
          Tomas Forsman made changes -
          Field Original Value New Value
          Description If a bean has a constructor argument which use generics, the injection fails with "org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to find a matching constructor".

          Example:
          package example;
          public interface Example<A> {}

          public class ExampleImpl implements Example<String> {}

          public class Service {
            private Example<String> example;
            public Service(Example<String> example) {
              this.example = example;
            }
          }

          <reference id="exampleReference" interface="example.Example"/>

          <bean id="proxyServiceInitialization" class="example.Service">
              <argument ref="exampleReference"/>
          </bean>

          Changing the constructor of Service to "public Service(Example example)" make it work, but it would be better to have it inject correctly with the generics intact.
          If a bean has a constructor argument which use generics, the injection fails with "org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to find a matching constructor".

          Example:
          package example;
          public interface Example<A> {}

          public class ExampleImpl implements Example<String> {}

          public class Service {
            private Example<String> example;
            public Service(Example<String> example) {
              this.example = example;
            }
          }


          <bean id="exampleReference" class="example.ExampleImpl"/>

          <bean id="proxyServiceInitialization" class="example.Service">
              <argument ref="exampleReference"/>
          </bean>

          Changing the constructor of Service to "public Service(Example example)" make it work, but it would be better to have it inject correctly with the generics intact.
          Tomas Forsman made changes -
          Description If a bean has a constructor argument which use generics, the injection fails with "org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to find a matching constructor".

          Example:
          package example;
          public interface Example<A> {}

          public class ExampleImpl implements Example<String> {}

          public class Service {
            private Example<String> example;
            public Service(Example<String> example) {
              this.example = example;
            }
          }


          <bean id="exampleReference" class="example.ExampleImpl"/>

          <bean id="proxyServiceInitialization" class="example.Service">
              <argument ref="exampleReference"/>
          </bean>

          Changing the constructor of Service to "public Service(Example example)" make it work, but it would be better to have it inject correctly with the generics intact.
          If a bean has a constructor argument which use generics, the injection fails with "org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to find a matching constructor".

          Example:
          package example;
          public interface Example<A> {}

          public class ExampleImpl implements Example<String> {}

          public class Service {
            private Example<String> example;
            public Service(Example<String> example) {
              this.example = example;
            }
          }


          <bean id="exampleBean" class="example.ExampleImpl"/>

          <bean id="proxyServiceInitialization" class="example.Service">
              <argument ref="exampleBean"/>
          </bean>

          Changing the constructor of Service to "public Service(Example example)" make it work, but it would be better to have it inject correctly with the generics intact.
          Tomas Forsman made changes -
          Description If a bean has a constructor argument which use generics, the injection fails with "org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to find a matching constructor".

          Example:
          package example;
          public interface Example<A> {}

          public class ExampleImpl implements Example<String> {}

          public class Service {
            private Example<String> example;
            public Service(Example<String> example) {
              this.example = example;
            }
          }


          <bean id="exampleBean" class="example.ExampleImpl"/>

          <bean id="proxyServiceInitialization" class="example.Service">
              <argument ref="exampleBean"/>
          </bean>

          Changing the constructor of Service to "public Service(Example example)" make it work, but it would be better to have it inject correctly with the generics intact.
          If a bean has a constructor argument which use generics, the injection fails with "org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to find a matching constructor".

          Example:
          package example;
          public interface Example<A> {}

          public class ExampleImpl implements Example<String> {}

          public class Service {
            private Example<String> example;
            public Service(Example<String> example) {
              this.example = example;
            }
          }

          <bean id="exampleBean" class="example.ExampleImpl"/>

          <bean id="serviceBean" class="example.Service">
              <argument ref="exampleBean"/>
          </bean>

          Changing the constructor of Service to "public Service(Example example)" make it work, but it would be better to have it inject correctly with the generics intact.
          Guillaume Nodet made changes -
          Link This issue duplicates ARIES-834 [ ARIES-834 ]
          Guillaume Nodet made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Assignee Guillaume Nodet [ gnt ]
          Fix Version/s blueprint-core-1.0.1 [ 12322492 ]
          Resolution Fixed [ 1 ]
          Hendy Irawan made changes -
          Link This issue relates to ARIES-960 [ ARIES-960 ]

            People

            • Assignee:
              Guillaume Nodet
              Reporter:
              Tomas Forsman
            • Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development