Skip to main content
Level 2
Oct 28, 2016 7:31 AM UTC
Solved

private org.apache.sling.api.resource.Resource were not able to be injected

Hi Team

        I am using sling models with sightly. I am trying to inject resource to my model as below. All the models are throwing same error saying Resource was not able to be injected. This was working sometimes before. Now for some reason I am getting this error. Could you please help

 

@Model(adaptables = Resource.class)
public class PdfDownloadModel {
    private final Logger LOG = LoggerFactory.getLogger(getClass());

    @Inject
    private Resource resource;

 

 

ERROR

org.apache.sling.models.impl.ModelAdapterFactory Required properties [private org.apache.sling.api.resource.Resource com.core.pdfdownload.models.PdfDownloadModel.resource] on model class class com.core.pdfdownload.models.PdfDownloadModel were not able to be injected.

Thanks in Advance

Veena

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Veena_VikramanAccepted solution
Level 2
Nov 7, 2016 1:19 PM UTC

Hi All

    It seems like my AEM instance got corrupted due to some compaction I have done. I have got a new Jar and setup the code and its working perfectly fine with my existing code base. 

    Thanks for all your help and time 

 

Thanks

Veena

4 replies

Feike_Visser1
Adobe Employee
Adobe Employee
Oct 28, 2016 1:29 PM UTC

You can better use @self to point to the resource

Translate
Veena_VikramanAuthorAccepted solution
Level 2
Nov 7, 2016 1:19 PM UTC

Hi All

    It seems like my AEM instance got corrupted due to some compaction I have done. I have got a new Jar and setup the code and its working perfectly fine with my existing code base. 

    Thanks for all your help and time 

 

Thanks

Veena

Translate
Feike_Visser1
Adobe Employee
Adobe Employee
Nov 7, 2016 1:33 PM UTC

Still I would use @Self in your case

Translate
Level 2
Nov 7, 2016 1:52 PM UTC

Sure Feike. I will refactor the code to use @self :) Thanks for pointing out to me :)

 

Thanks

Veena

Translate