java.lang.NullPointerException

Spring JIRA | Oliver Gierke | 5 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Assume you have a repository like this: {code:java} interface OrderRepository extends CrudRepository<Order, Long> { List<Order> findByCustomer(Customer customer); } {code} If the method now gets exposed, how shall one provide the {{Customer}} object for the {{GET}} request? Currently a plain call to {code} http://localhost:8080/order/search/findByCustomer {code} causes a {noformat} java.lang.NullPointerException at java.io.StringReader.<init>(StringReader.java:33) at org.codehaus.jackson.JsonFactory.createJsonParser(JsonFactory.java:636) at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1863) at org.springframework.data.rest.webmvc.RepositoryRestController.query(RepositoryRestController.java:418) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778) at javax.servlet.http.HttpServlet.service(HttpServlet.java:735) at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:643) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:450) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:131) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1067) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:377) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1001) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111) at org.eclipse.jetty.server.Server.handle(Server.java:360) at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454) at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890) at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:622) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538) at java.lang.Thread.run(Thread.java:680) {noformat}

    Spring JIRA | 5 years ago | Oliver Gierke
    java.lang.NullPointerException
  2. 0

    Assume you have a repository like this: {code:java} interface OrderRepository extends CrudRepository<Order, Long> { List<Order> findByCustomer(Customer customer); } {code} If the method now gets exposed, how shall one provide the {{Customer}} object for the {{GET}} request? Currently a plain call to {code} http://localhost:8080/order/search/findByCustomer {code} causes a {noformat} java.lang.NullPointerException at java.io.StringReader.<init>(StringReader.java:33) at org.codehaus.jackson.JsonFactory.createJsonParser(JsonFactory.java:636) at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1863) at org.springframework.data.rest.webmvc.RepositoryRestController.query(RepositoryRestController.java:418) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778) at javax.servlet.http.HttpServlet.service(HttpServlet.java:735) at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:643) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:450) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:131) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1067) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:377) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1001) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111) at org.eclipse.jetty.server.Server.handle(Server.java:360) at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454) at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890) at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:622) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538) at java.lang.Thread.run(Thread.java:680) {noformat}

    Spring JIRA | 5 years ago | Oliver Gierke
    java.lang.NullPointerException
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.NullPointerException

    No message provided

    at java.io.StringReader.<init>()
  2. Java RT
    StringReader.<init>
    1. java.io.StringReader.<init>(StringReader.java:33)
    1 frame
  3. Jackson
    JsonFactory.createJsonParser
    1. org.codehaus.jackson.JsonFactory.createJsonParser(JsonFactory.java:636)
    1 frame
  4. Data Mapper for Jackson
    ObjectMapper.readValue
    1. org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1863)
    1 frame
  5. Spring Data REST - WebMVC
    RepositoryRestController.query
    1. org.springframework.data.rest.webmvc.RepositoryRestController.query(RepositoryRestController.java:418)
    1 frame
  6. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    4. java.lang.reflect.Method.invoke(Method.java:597)
    4 frames
  7. Spring
    InvocableHandlerMethod.invokeForRequest
    1. org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
    2. org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
    2 frames
  8. Spring MVC
    FrameworkServlet.doGet
    1. org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
    2. org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
    3. org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
    4. org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
    5. org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
    6. org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
    7. org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    8. org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
    8 frames
  9. JavaServlet
    HttpServlet.service
    1. javax.servlet.http.HttpServlet.service(HttpServlet.java:735)
    2. javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    2 frames
  10. Jetty
    AsyncHttpConnection.handle
    1. org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:643)
    2. org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:450)
    3. org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:131)
    4. org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
    5. org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
    6. org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1067)
    7. org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:377)
    8. org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
    9. org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1001)
    10. org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)
    11. org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)
    12. org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
    13. org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
    14. org.eclipse.jetty.server.Server.handle(Server.java:360)
    15. org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454)
    16. org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890)
    17. org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944)
    18. org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630)
    19. org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
    20. org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77)
    20 frames
  11. GWT dev
    SelectChannelEndPoint$1.run
    1. org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:622)
    2. org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46)
    2 frames
  12. Jetty
    QueuedThreadPool$3.run
    1. org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603)
    2. org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538)
    2 frames
  13. Java RT
    Thread.run
    1. java.lang.Thread.run(Thread.java:680)
    1 frame