java.lang.NullPointerException

Spring JIRA | yangjun | 2 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

    spring data neo4j not lookup node

    Stack Overflow | 2 years ago
    java.lang.NullPointerException
  2. 0

    i set some value to my neo4jdb,an i can see them in web-browser,so my db have nodes.but when i look up them,it returns null.what is wrong?my spring data neo4j version is 3.2.2.thanks for help,i have in disturbing with this four a long time {code} package com.oberon.fm.neo4j.service; import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.graphdb.Transaction; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.neo4j.support.Neo4jTemplate; import org.springframework.data.neo4j.template.Neo4jOperations; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.oberon.fm.domain.Movie; import com.oberon.fm.domain.User; @Service public class DatabasePopulator { @Autowired Neo4jOperations operation; @Autowired Neo4jTemplate template; private final static Logger log = LoggerFactory .getLogger(DatabasePopulator.class); @Transactional public void populateWithSomeTestData() { System.out.println("==== Populating ===="); GraphDatabaseService graphDb = template.getGraphDatabaseService(); Transaction tx = graphDb.beginTx(); try { User user = new User("micha", "Micha", "password", User.Roles.ROLE_USER); User me = template.save(user); User yang = template.save(new User("yang", "Yang", "password", User.Roles.ROLE_USER)); User ollie = template.save(new User("ollie", "Olliver", "password", User.Roles.ROLE_USER)); me.addFriend(ollie); // id and title Movie forrestGump = template.save(new Movie("1", "Forrest Gump")); me.rate(template, forrestGump, 5, "Best of the series"); tx.success(); String name = me.getName(); log.debug(name); } catch (Exception e) { e.printStackTrace(); } finally { tx.close(); System.out.println("==== endPopulating ===="); } } @Transactional public void cleanDb() { new Neo4jDatabaseCleaner(template).cleanDb(); } public boolean loginCheck(String userName, String password) { boolean rtn = false; GraphDatabaseService graphDb = template.getGraphDatabaseService(); Transaction tx = graphDb.beginTx(); try { User test = operation.lookup(User.class, "name", userName) .to(User.class).singleOrNull(); System.out.println("2" + test); User loginUser = template.lookup(User.class, "name", userName) .to(User.class).singleOrNull(); System.out.println("3" + loginUser); String userPassword = loginUser.getPassword(); System.out.println(userPassword); if (new Md5PasswordEncoder().encodePassword(password, User.SALT) .equals(userPassword)) { rtn = true; } tx.success(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { tx.close(); } return rtn; } {code} {code} error info 2null 3null java.lang.NullPointerException at com.oberon.fm.neo4j.service.DatabasePopulator.loginCheck(DatabasePopulator.java:86) at com.oberon.fm.neo4j.service.DatabasePopulator$$FastClassBySpringCGLIB$$c9138765.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:649) at com.oberon.fm.neo4j.service.DatabasePopulator$$EnhancerBySpringCGLIB$$27698688.loginCheck(<generated>) at com.oberon.fm.controller.AuthController.loginCheck(AuthController.java:41) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:177) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:446) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:434) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868) at javax.servlet.http.HttpServlet.service(HttpServlet.java:644) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658) at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1556) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1513) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) {code}

    Spring JIRA | 2 years ago | yangjun
    java.lang.NullPointerException
  3. 0

    i set some value to my neo4jdb,an i can see them in web-browser,so my db have nodes.but when i look up them,it returns null.what is wrong?my spring data neo4j version is 3.2.2.thanks for help,i have in disturbing with this four a long time {code} package com.oberon.fm.neo4j.service; import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.graphdb.Transaction; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.neo4j.support.Neo4jTemplate; import org.springframework.data.neo4j.template.Neo4jOperations; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.oberon.fm.domain.Movie; import com.oberon.fm.domain.User; @Service public class DatabasePopulator { @Autowired Neo4jOperations operation; @Autowired Neo4jTemplate template; private final static Logger log = LoggerFactory .getLogger(DatabasePopulator.class); @Transactional public void populateWithSomeTestData() { System.out.println("==== Populating ===="); GraphDatabaseService graphDb = template.getGraphDatabaseService(); Transaction tx = graphDb.beginTx(); try { User user = new User("micha", "Micha", "password", User.Roles.ROLE_USER); User me = template.save(user); User yang = template.save(new User("yang", "Yang", "password", User.Roles.ROLE_USER)); User ollie = template.save(new User("ollie", "Olliver", "password", User.Roles.ROLE_USER)); me.addFriend(ollie); // id and title Movie forrestGump = template.save(new Movie("1", "Forrest Gump")); me.rate(template, forrestGump, 5, "Best of the series"); tx.success(); String name = me.getName(); log.debug(name); } catch (Exception e) { e.printStackTrace(); } finally { tx.close(); System.out.println("==== endPopulating ===="); } } @Transactional public void cleanDb() { new Neo4jDatabaseCleaner(template).cleanDb(); } public boolean loginCheck(String userName, String password) { boolean rtn = false; GraphDatabaseService graphDb = template.getGraphDatabaseService(); Transaction tx = graphDb.beginTx(); try { User test = operation.lookup(User.class, "name", userName) .to(User.class).singleOrNull(); System.out.println("2" + test); User loginUser = template.lookup(User.class, "name", userName) .to(User.class).singleOrNull(); System.out.println("3" + loginUser); String userPassword = loginUser.getPassword(); System.out.println(userPassword); if (new Md5PasswordEncoder().encodePassword(password, User.SALT) .equals(userPassword)) { rtn = true; } tx.success(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { tx.close(); } return rtn; } {code} {code} error info 2null 3null java.lang.NullPointerException at com.oberon.fm.neo4j.service.DatabasePopulator.loginCheck(DatabasePopulator.java:86) at com.oberon.fm.neo4j.service.DatabasePopulator$$FastClassBySpringCGLIB$$c9138765.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:649) at com.oberon.fm.neo4j.service.DatabasePopulator$$EnhancerBySpringCGLIB$$27698688.loginCheck(<generated>) at com.oberon.fm.controller.AuthController.loginCheck(AuthController.java:41) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:177) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:446) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:434) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868) at javax.servlet.http.HttpServlet.service(HttpServlet.java:644) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658) at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1556) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1513) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) {code}

    Spring JIRA | 2 years ago | yangjun
    java.lang.NullPointerException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    I can not get the session which i had set

    Stack Overflow | 2 years ago
    java.lang.NullPointerException: null

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at com.oberon.fm.neo4j.service.DatabasePopulator.loginCheck()
    2. com.oberon.fm
      DatabasePopulator$$FastClassBySpringCGLIB$$c9138765.invoke
      1. com.oberon.fm.neo4j.service.DatabasePopulator.loginCheck(DatabasePopulator.java:86)
      2. com.oberon.fm.neo4j.service.DatabasePopulator$$FastClassBySpringCGLIB$$c9138765.invoke(<generated>)
      2 frames
    3. Spring Core
      MethodProxy.invoke
      1. org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
      1 frame
    4. Spring AOP
      CglibAopProxy$DynamicAdvisedInterceptor.intercept
      1. org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:649)
      1 frame
    5. com.oberon.fm
      AuthController.loginCheck
      1. com.oberon.fm.neo4j.service.DatabasePopulator$$EnhancerBySpringCGLIB$$27698688.loginCheck(<generated>)
      2. com.oberon.fm.controller.AuthController.loginCheck(AuthController.java:41)
      2 frames
    6. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      4. java.lang.reflect.Method.invoke(Method.java:483)
      4 frames
    7. Spring
      HandlerMethodInvoker.invokeHandlerMethod
      1. org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:177)
      1 frame
    8. Spring MVC
      FrameworkServlet.doPost
      1. org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:446)
      2. org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:434)
      3. org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
      4. org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
      5. org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
      6. org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868)
      6 frames
    9. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
      1 frame
    10. Spring MVC
      FrameworkServlet.service
      1. org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
      1 frame
    11. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
      1 frame
    12. Glassfish Core
      ApplicationFilterChain.doFilter
      1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
      2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      2 frames
    13. Tomcat WS
      WsFilter.doFilter
      1. org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      1 frame
    14. Glassfish Core
      ApplicationFilterChain.doFilter
      1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      2 frames
    15. Spring
      OncePerRequestFilter.doFilter
      1. org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
      2. org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      2 frames
    16. Glassfish Core
      CoyoteAdapter.service
      1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      3. org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
      4. org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
      5. org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
      6. org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
      7. org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
      8. org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
      9. org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
      10. org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537)
      10 frames
    17. Grizzly HTTP
      NioEndpoint$SocketProcessor.run
      1. org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085)
      2. org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)
      3. org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
      4. org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1556)
      5. org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1513)
      5 frames
    18. Java RT
      ThreadPoolExecutor$Worker.run
      1. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      2 frames
    19. Tomcat Util
      TaskThread$WrappingRunnable.run
      1. org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      1 frame
    20. Java RT
      Thread.run
      1. java.lang.Thread.run(Thread.java:745)
      1 frame