darrachequesne / spring-data-jpa-datatables

Spring Data JPA extension to work with the great jQuery plugin DataTables (https://datatables.net/)
Apache License 2.0
440 stars 174 forks source link

Getting null java.lang.NullPointerException on repo.findAll(input) #123

Closed akhilsahu closed 3 years ago

akhilsahu commented 3 years ago

I have configured all according to documentation

Create a DataTableConfig File: @Configuration @EnableJpaRepositories(repositoryFactoryBeanClass = DataTablesRepositoryFactoryBean.class, basePackages ="com.spring.demo.datatableRepository" ) public class DataTablesConfiguration { } Create a rest controller as :

@JsonView(DataTablesOutput.View.class) @RequestMapping(value = "/get_data", method = RequestMethod.POST) public DataTablesOutput<User> listPOST(@Valid @RequestBody DataTablesInput input) throws Exception{ System.out.println("DATA POST HERE:==>"+input); try { DataTablesOutput<User> adt = userDataTableRepo.findAll(input); // returns nullpointer exception System.out.println("DATA adt HERE:==>"+adt); System.out.println(adt); return adt; }catch (Exception e){ e.printStackTrace(); System.out.print("eer"); } return new DataTablesOutput<>(); }

Now any repo I call are returning Nullpointerexception it was working fine earlier but dont know why. I tried setting the @EnableJpaRepositories(basePackages = "com.spring.demo.dao") in the spring boot App file. In DAO other repositories are there. which are also returning null now. Interface extends DataTableRepo as specified public interface UserDataTableRepo extends DataTablesRepository<User,Integer> {} Struggling with this since last day.