Uploaded image for project: 'Spring Data Neo4j'
  1. Spring Data Neo4j
  2. DATAGRAPH-344

While using spring data with neo4j not able to process the paths

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.1.RC4
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Environment:
      2.1.RC4 Spring tih neo4j
      1.8.M06 neo4j

      Description

      Hi,
      I was using spring data with neo4j.

      I used @Query annotation to place the query in the repository,the query was as follows

      @Query(value = "START me=node({0}), friend=node({1}) "
          + "MATCH p=shortestPath(me-[:ACTIVEFRIEND*..]->friend)"
          + " RETURN p")
          public Iterable<EntityPath<User, User>> getShortestPathBetween(User a, User b);

      In Controller I am accesing it as

       Iterable<EntityPath<User, User>> shortestPathBetween = this.queryService.getShortestPathBetween(user, friend);
              for (EntityPath<User, User> path : shortestPathBetween) {
                  Iterator<User> iter = path.<User>nodeEntities().iterator();
              }

      When it tries to access path.nodeEntities ..It is giving the following error...

      nested exception is java.lang.NullPointerException] with root cause
      java.lang.NullPointerException
          at org.springframework.data.neo4j.support.path.ConvertingEntityPath.nodes(ConvertingEntityPath.java:137)
          at org.springframework.data.neo4j.support.path.ConvertingEntityPath.nodeEntities(ConvertingEntityPath.java:69)
          at com.laindain.cms.controller.QueryController.getShortestPathBetween(QueryController.java:194)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:601)
          at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:212)
          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:900)
          at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
          at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
          at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
          at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
          at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
          at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
          at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1822)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
          at java.lang.Thread.run(Thread.java:722)

        Activity

        Hide
        mhunger Michael Hunger added a comment -

        What kinds of paths are returned if your run this query? Could it be that the path is empty?

        Show
        mhunger Michael Hunger added a comment - What kinds of paths are returned if your run this query? Could it be that the path is empty?
        Hide
        mhunger Michael Hunger added a comment -

        Do you have any more information for us? Otherwise I have to close this issue as not reproducable!?

        Show
        mhunger Michael Hunger added a comment - Do you have any more information for us? Otherwise I have to close this issue as not reproducable!?
        Hide
        btysgtmajor Duncan Brown added a comment - - edited

        I'm having similar issues.

        It's running on Neo4j server (i.e. not embedded).

        Neo4j 1.9.4
        SDN 2.3.1.RELEASE

        @Query("START n=node(1), x=node(97) MATCH p = shortestPath( n-[*]-x ) RETURN p")
        	EndResult<EntityPath<Game, Game> > getPath();

        I know this query is valid as I can run it through the webadmin of my Neo4j installation. The query is returning results in the webadmin.

        EntityPath<Game, Game> thePath = gameRepository.getPath().single();
        Iterable<Node> nodes= thePath .nodes();	// THIS IS WHERE IT FAILS AND CRASHES

        Stack trace is here:

        SEVERE: Servlet.service() for servlet [vonneumannsweb] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
        java.lang.NullPointerException
        	at org.springframework.data.neo4j.support.path.ConvertingEntityPath.nodes(ConvertingEntityPath.java:137)
        	at com.company.vonneumanns.controllers.GameController.index(GameController.java:66)
        	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.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
        	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
        	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
        	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:621)
        	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
        	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
        	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
        	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
        	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
        	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
        	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
        	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
        	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
        	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
        	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
        	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        	at java.lang.Thread.run(Thread.java:662)

        I would love to see this issue resolved. If there's any further info I can give, please let me know.

        Show
        btysgtmajor Duncan Brown added a comment - - edited I'm having similar issues. It's running on Neo4j server (i.e. not embedded). Neo4j 1.9.4 SDN 2.3.1.RELEASE @Query("START n=node(1), x=node(97) MATCH p = shortestPath( n-[*]-x ) RETURN p") EndResult<EntityPath<Game, Game> > getPath(); I know this query is valid as I can run it through the webadmin of my Neo4j installation. The query is returning results in the webadmin. EntityPath<Game, Game> thePath = gameRepository.getPath().single(); Iterable<Node> nodes= thePath .nodes(); // THIS IS WHERE IT FAILS AND CRASHES Stack trace is here: SEVERE: Servlet.service() for servlet [vonneumannsweb] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause java.lang.NullPointerException at org.springframework.data.neo4j.support.path.ConvertingEntityPath.nodes(ConvertingEntityPath.java:137) at com.company.vonneumanns.controllers.GameController.index(GameController.java:66) 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.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424) 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:621) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) I would love to see this issue resolved. If there's any further info I can give, please let me know.
        Hide
        btysgtmajor Duncan Brown added a comment -

        Also, for the above query, here's the result I get from the webadmin data browser:

        {"start":"http://theserver:7474/db/data/node/1","nodes":["http://theserver:7474/db/data/node/1","http://theserver:7474/db/data/node/10","http://theserver:7474/db/data/node/97"],"length":2,"relationships":["http://theserver:7474/db/data/relationship/8","http://theserver:7474/db/data/relationship/89"],"end":"http://theserver:7474/db/data/node/97"}

        Show
        btysgtmajor Duncan Brown added a comment - Also, for the above query, here's the result I get from the webadmin data browser: {"start":"http://theserver:7474/db/data/node/1","nodes":["http://theserver:7474/db/data/node/1","http://theserver:7474/db/data/node/10","http://theserver:7474/db/data/node/97"],"length":2,"relationships":["http://theserver:7474/db/data/relationship/8","http://theserver:7474/db/data/relationship/89"],"end":"http://theserver:7474/db/data/node/97"}
        Hide
        Xilhion Xilhion added a comment -

        Hi, i am having this very same issue on SDN 3.1.1.RELEASE .
        It appears to be linked to the usage of SpringRestGraphDatabase has, turning to an embedded database fix the issue.

        Is there a workaround to still be able to search path while using a rest graph database ?

        Show
        Xilhion Xilhion added a comment - Hi, i am having this very same issue on SDN 3.1.1.RELEASE . It appears to be linked to the usage of SpringRestGraphDatabase has, turning to an embedded database fix the issue. Is there a workaround to still be able to search path while using a rest graph database ?
        Hide
        TSchulz Tilo Schulz added a comment - - edited

        Same on SDN 3.2.1.RELEASE and Neo4J 2.1.6. ShortestPath queries like above work with the embedded version but crash with Rest.

        For the time being could this be a valid workaround. At least I'm comfortable with it:

          Path path = GraphAlgoFactory.shortestPath((PathExpander) StandardExpander.DEFAULT.add(RelTypes.CONNECTED_TO), 10)
                            .findSinglePath(repository.findByWaypointId(startId).getPersistentState(),
                                    repository.findByWaypointId(destinationId).getPersistentState());
          if (path == null) {
            return Collections.emptyList();
          } else {
            for(Relationship rel : path.relationships()) {
              result.add((String) rel.getProperty("edgeId"));
            }
          }

        Is there still no effort on the case?

        Show
        TSchulz Tilo Schulz added a comment - - edited Same on SDN 3.2.1.RELEASE and Neo4J 2.1.6. ShortestPath queries like above work with the embedded version but crash with Rest. For the time being could this be a valid workaround. At least I'm comfortable with it: Path path = GraphAlgoFactory.shortestPath((PathExpander) StandardExpander.DEFAULT.add(RelTypes.CONNECTED_TO), 10 ) .findSinglePath(repository.findByWaypointId(startId).getPersistentState(), repository.findByWaypointId(destinationId).getPersistentState()); if (path == null ) { return Collections.emptyList(); } else { for (Relationship rel : path.relationships()) { result.add((String) rel.getProperty( "edgeId" )); } } Is there still no effort on the case?
        Hide
        mhunger Michael Hunger added a comment -

        I can try to look into it in the next days.

        Show
        mhunger Michael Hunger added a comment - I can try to look into it in the next days.
        Hide
        Sean Smith Sean Smith added a comment -

        Any progress with this one?

        Show
        Sean Smith Sean Smith added a comment - Any progress with this one?
        Hide
        nmervaillie Nicolas Mervaillie added a comment -

        In order to give users a better vision of what’s happening on SDN, we are bulk closing several issues because they are no more relevant, or related to old and un-maintained SDN versions.
        We tried to keep the issues that are still relevant, like feature requests that are still absent from SDN. However, some may have been closed by error. If so, please feel free to reopen.

        Show
        nmervaillie Nicolas Mervaillie added a comment - In order to give users a better vision of what’s happening on SDN, we are bulk closing several issues because they are no more relevant, or related to old and un-maintained SDN versions. We tried to keep the issues that are still relevant, like feature requests that are still absent from SDN. However, some may have been closed by error. If so, please feel free to reopen.

          People

          • Assignee:
            mhunger Michael Hunger
            Reporter:
            hemanti3t Hemant
            Last updater:
            Nicolas Mervaillie
          • Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: