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

Konrad Windszus updated SLING-10935:
------------------------------------
    Description: 
When constructor injection is used and a reference is only used as argument to 
the constructor it gets an automatically generated [reference 
name|http://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.component.html#org.osgi.service.component.annotations.Reference.name--]
 by Bnd like "$001" which leads to the following error message when a reference 
cannot be injected:

{code}
org.apache.sling.testing.mock.osgi.ReferenceViolationException: Unable to 
inject mandatory reference '$001' for class <MyDSComponentClass> : no matching 
services were found.
        at 
org.apache.sling.testing.mock.osgi.OsgiServiceUtil.buildConstructorInjectionValue(OsgiServiceUtil.java:568)
        at 
org.apache.sling.testing.mock.osgi.OsgiServiceUtil.buildConstructorInjectionValues(OsgiServiceUtil.java:533)
        at 
org.apache.sling.testing.mock.osgi.OsgiServiceUtil.instantiateServiceWithActivateInject(OsgiServiceUtil.java:493)
        at 
org.apache.sling.testing.mock.osgi.OsgiServiceUtil.activateInjectServices(OsgiServiceUtil.java:456)
        at 
org.apache.sling.testing.mock.osgi.MockOsgi.activateInjectServices(MockOsgi.java:190)
        at 
org.apache.sling.testing.mock.osgi.context.OsgiContextImpl.registerInjectActivateService(OsgiContextImpl.java:191)
        at 
org.apache.sling.testing.mock.osgi.context.OsgiContextImpl.registerInjectActivateService(OsgiContextImpl.java:179)
        ...
{code}


In addition to the reference name the to be injected class should be emitted 
and also it should be mentioned that a constructor argument cannot be resolved.

  was:
When constructor injection is used and a reference is only used as argument to 
the constructor it gets an automatically generated name by Bnd like "$001" 
which leads to the following error message when a reference cannot be injected:

{code}
org.apache.sling.testing.mock.osgi.ReferenceViolationException: Unable to 
inject mandatory reference '$001' for class <MyDSComponentClass> : no matching 
services were found.
        at 
org.apache.sling.testing.mock.osgi.OsgiServiceUtil.buildConstructorInjectionValue(OsgiServiceUtil.java:568)
        at 
org.apache.sling.testing.mock.osgi.OsgiServiceUtil.buildConstructorInjectionValues(OsgiServiceUtil.java:533)
        at 
org.apache.sling.testing.mock.osgi.OsgiServiceUtil.instantiateServiceWithActivateInject(OsgiServiceUtil.java:493)
        at 
org.apache.sling.testing.mock.osgi.OsgiServiceUtil.activateInjectServices(OsgiServiceUtil.java:456)
        at 
org.apache.sling.testing.mock.osgi.MockOsgi.activateInjectServices(MockOsgi.java:190)
        at 
org.apache.sling.testing.mock.osgi.context.OsgiContextImpl.registerInjectActivateService(OsgiContextImpl.java:191)
        at 
org.apache.sling.testing.mock.osgi.context.OsgiContextImpl.registerInjectActivateService(OsgiContextImpl.java:179)
        ...
{code}


> Improve error message when mandatory references cannot be resolved for 
> constructor injection
> --------------------------------------------------------------------------------------------
>
>                 Key: SLING-10935
>                 URL: https://issues.apache.org/jira/browse/SLING-10935
>             Project: Sling
>          Issue Type: Improvement
>          Components: Testing
>    Affects Versions: Testing OSGi Mock 3.1.4
>            Reporter: Konrad Windszus
>            Assignee: Konrad Windszus
>            Priority: Major
>
> When constructor injection is used and a reference is only used as argument 
> to the constructor it gets an automatically generated [reference 
> name|http://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.component.html#org.osgi.service.component.annotations.Reference.name--]
>  by Bnd like "$001" which leads to the following error message when a 
> reference cannot be injected:
> {code}
> org.apache.sling.testing.mock.osgi.ReferenceViolationException: Unable to 
> inject mandatory reference '$001' for class <MyDSComponentClass> : no 
> matching services were found.
>       at 
> org.apache.sling.testing.mock.osgi.OsgiServiceUtil.buildConstructorInjectionValue(OsgiServiceUtil.java:568)
>       at 
> org.apache.sling.testing.mock.osgi.OsgiServiceUtil.buildConstructorInjectionValues(OsgiServiceUtil.java:533)
>       at 
> org.apache.sling.testing.mock.osgi.OsgiServiceUtil.instantiateServiceWithActivateInject(OsgiServiceUtil.java:493)
>       at 
> org.apache.sling.testing.mock.osgi.OsgiServiceUtil.activateInjectServices(OsgiServiceUtil.java:456)
>       at 
> org.apache.sling.testing.mock.osgi.MockOsgi.activateInjectServices(MockOsgi.java:190)
>       at 
> org.apache.sling.testing.mock.osgi.context.OsgiContextImpl.registerInjectActivateService(OsgiContextImpl.java:191)
>       at 
> org.apache.sling.testing.mock.osgi.context.OsgiContextImpl.registerInjectActivateService(OsgiContextImpl.java:179)
>       ...
> {code}
> In addition to the reference name the to be injected class should be emitted 
> and also it should be mentioned that a constructor argument cannot be 
> resolved.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to