[DATAGRAPH-344] While using spring data with neo4j not able to process the paths Created: 13/Mar/13  Updated: 02/Sep/17  Resolved: 02/Sep/17

Status: Closed
Project: Spring Data Neo4j
Component/s: None
Affects Version/s: 2.1.RC4
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Hemant Assignee: Michael Hunger
Resolution: Won't Fix Votes: 2
Labels: mvc
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

2.1.RC4 Spring tih neo4j
1.8.M06 neo4j


Last updater: Nicolas Mervaillie

 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)



 Comments   
Comment by Michael Hunger [ 27/May/13 ]

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

Comment by Michael Hunger [ 02/Sep/13 ]

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

Comment by Duncan Brown [ 25/Oct/13 ]

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.

Comment by Duncan Brown [ 25/Oct/13 ]

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"}

Comment by Xilhion [ 13/Aug/14 ]

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 ?

Comment by Tilo Schulz [ 29/Nov/14 ]

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?

Comment by Michael Hunger [ 29/Nov/14 ]

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

Comment by Sean Smith [ 14/Mar/15 ]

Any progress with this one?

Comment by Nicolas Mervaillie [ 02/Sep/17 ]

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.

Generated at Mon Oct 23 11:45:01 UTC 2017 using JIRA 6.4.14#64029-sha1:ae256fe0fbb912241490ff1cecfb323ea0905ca5.