You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aries.apache.org by "Tomas Forsman (Updated) (JIRA)" <ji...@apache.org> on 2012/04/06 13:55:23 UTC

[jira] [Updated] (ARIES-843) Bean can not be created if constructor argument use generics

     [ https://issues.apache.org/jira/browse/ARIES-843?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tomas Forsman updated ARIES-843:
--------------------------------

    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.

  was:
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.

    
> Bean can not be created if constructor argument use generics
> ------------------------------------------------------------
>
>                 Key: ARIES-843
>                 URL: https://issues.apache.org/jira/browse/ARIES-843
>             Project: Aries
>          Issue Type: Bug
>          Components: Blueprint
>    Affects Versions: 0.3
>            Reporter: Tomas Forsman
>
> 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.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira