Multifield Model Null pointer exception
Dear All,
We have implemented Multifield component along with Model using Resource.
But we are getting null pointer exception when we are trying to get use Resource object.
Core Class:
import org.apache.sling.models.annotations.Model;
import org.apache.sling.api.resource.Resource;
@Model(
adaptables = {Resource.class},
adapters = {MultifieldModel.class},
defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL
)
public class MultifieldModelImpl implements MultifieldModel {
@586265
Resource componentResource;
public List<Map<String, String>> getDetailsWithMap() {
List<Map<String, String>> detailsMap=new ArrayList<>();
try {
Resource detailfield=componentResource.getChild("nodename/path");
}
}
}
Multifield Interface :
public interface MultifieldModel {
String getFieldTitle();
List<Map<String,String>> getDetailsWithMap();
}
in component we using this by data sly:
data-sly-use.field="pathtoclass.MultifieldModel"
when we render pages using this Model componentResource(
reosurce object) is giving as null.
This same code is workign fine in Dev env in both author- publisher and in production authors but only giving error in Production publishers.
Request you please suggest things we can modify or check in pub to make it work.
Thanks in advance