I am getting a NullPointerException on AlertService#findAll() method:

java.lang.NullPointerExceptioncom.t2.claims.servic es.AlertService.findAll(AlertService.java:24)com.t 2.claims.controllers.AlertIndexController.doAfterC ompose(AlertIndexController.java:28)This is the findAll() method:

public List findAll() { Query query = new Query(where("id").exists(true)); return mongoTemplate.find(query, Alert.class);}The whole AlertService is as such:

package com.t2.claims.services;import java.util.List;import javax.annotation.Resource;import org.springframework.data.mongodb.core.MongoTemplat e;import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Update ;import org.springframework.stereotype.Service;import org.springframework.transaction.annotation.Transac tional;import com.t2.claims.models.Alert;import static org.springframework.data.mongodb.core.query.Criter ia.where;@Service("alertService")@Transactionalpub lic class AlertService { @Resource(name="mongoTemplate") private MongoTemplate mongoTemplate; public List findAll() { Query query = new Query(where("id").exists(true)); return mongoTemplate.find(query, Alert.class); } public void add(Alert alert) { try { mongoTemplate.insert(alert); } catch(Exception e) {} } public void update(Alert alert) { Query query = new Query(where("id").is(alert.getId())); try { Update update = new Update(); update.set("assignedUser", alert.getAssignedUser()); update.set("status", alert.getStatus()); update.set("category", alert.getCategory()); update.set("vehicleStatus", alert.getVehicleStatus()); update.set("brand", alert.getBrand()); mongoTemplate.updateMulti(query, update, Alert.class); } catch(Exception e) {} } public void delete(Alert alert) { try { Query query = new Query(where("id").is(alert.getId())); // Run the query and delete the entry mongoTemplate.remove(query, Alert.class); } catch(Exception e) {} }}It may be easier to check out my IntegrateMongo branch on Github to have at look in more detail. https://github.com/georgeotoole/T2Cl...IntegrateMongo
I can't understand if there is an issue with my code or perhaps mongo on my machine .. ?
Thanks


Check Solution