When I call count() method on the org.springframework.data.repository.CrudRepository.count() , ElasticsearchRepository.count().... it throws NullPointerException


(dpr) #1

I am using spring-data-elasticsearch apis. When I call count() method on the org.springframework.data.repository.CrudRepository.count() , ElasticsearchRepository.count().... it throws NullPointerException.. I checked elasticsearch is working. But still gettting this error. Please suggest what can be done..

I posted in Spring forums, but there is no repsonse.

Thanks in advance.


(dpr) #2

When I use @Autowired like

@Autowired
priavate SomeRepository someRepository;

someRepository.count() --> throws nullPointerException

I saw that someRepository reference variable is having null value. How can I use it in my spring application.
This is the interface I created. { interface SomeRepository extends ElasticsearchRepository<> {} }

Please suggest...

Thanks in advance...


(Daniel Mitterdorfer) #3

I am sorry to say that but the issue is entirely unrelated to Elasticsearch. Your dependency on someRepository is not injected by Spring. You might want to check whether the respective packages are included in the classpath scan of Spring and that your repository is properly configured (for details see the Spring data docs).


(system) #4