Sling model all fields null
I had my sling models working fine in 6.1 but I am having trouble in 6.2 even a basic example does not work. The model itself is setup and is not null but all the fields with inject on them are null but the model itself is initialised and not null.
Model is:
package com.test.ecomm.aem.testing.core.models.components.content; import javax.inject.Inject; import org.apache.sling.api.resource.Resource; import org.apache.sling.models.annotations.Model; @Model(adaptables = Resource.class) public class TestModel { @Inject private String test; public String getTest() { return test; } public void setTest(String test) { this.test = test; } }And the call to initialise the model is:
Resource resource = resourceResolver.getResource("/content/testSite/en/test5/jcr:content/par/testing"); TestModel test = resource.adaptTo(TestModel.class); System.out.println("tom model is " + test.getTest());