spring-projects / spring-projects/spring-data-rest
Null-pointer exception if classpath contains Spring Data Elasticsearch Repositories [DATAREST-109]
@odrotbohm is already working on this.
Since Dec 31, 2020.
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
Petar Tahchiev opened DATAREST-109 and commented
Hi guys,
I'm trying out the spring data project, and I really love it :) ... However, I get this null-pointer exception, because my classpath contains a spring-data-elasticsearch repository:
2013-08-20 16:16:18,838 [qtp1098209814-127] ERROR org.springframework.data.rest.webmvc.RepositoryEntityController -
java.lang.NullPointerException
at org.springframework.data.rest.repository.support.RepositoryInformationSupport.findRepositoryInfoFor(RepositoryInformationSupport.java:61)
at org.springframework.data.rest.webmvc.RepositoryInformationHandlerMethodArgumentResolver.resolveArgument(RepositoryInformationHandlerMethodArgumentResolver.java:44)
at org.springframework.data.rest.webmvc.RepositoryRestRequestHandlerMethodArgumentResolver.resolveArgument(RepositoryRestRequestHandlerMethodArgumentResolver.java:46)
at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:77)
at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:162)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:123)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:735)
I debugged it, and I saw that here in this for loop:
for(Class<?> domainType : repositories) {
RepositoryInformation repoInfo = findRepositoryInfoFor(domainType);
ResourceMapping mapping = getResourceMapping(config, repoInfo);
if(pathSegment.equals(mapping.getPath()) && mapping.isExported()) {
return repoInfo;
}
}
repoInfo gets resolved as null and mapping as well. Then inside the if statement the null-pointer occurs. BTW, I think the same error will occur if the classpath contains spring-data-solr repositories.
Cheers
Affects: 1.1.0.M1
Attachments:
- DATAREST-109.patch (1.01 kB)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.