Announcement Announcement Module
Collapse
No announcement yet.
Using repository's findBy___Like method throws a NullPointerException on a space Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using repository's findBy___Like method throws a NullPointerException on a space

    Hi,

    I'm using Spring Data Neo4j 2.1.0.BUILD-SNAPSHOT and I've created a repository (Spring Data Neo4j GraphRepository) with that method in it:

    Code:
    Page<SimpleCustomer> findByEntityIdLike(String entityId, Pageable page);
    It works very well; But when there's a space in the criteria, it throws a NullPointerException. For example, if I pass a field like: "*hello world*" (without the quotes), I receive this:

    Code:
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: Error executing statement start `simpleCustomer`=node:`search`({0}) return `simpleCustomer` skip 0 limit 5; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: Error executing statement start `simpleCustomer`=node:`search`({0}) return `simpleCustomer` skip 0 limit 5; nested exception is java.lang.NullPointerException
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:681)
    	org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:585)
    [...]
    root cause
    
    java.lang.NullPointerException
    	org.apache.lucene.util.SimpleStringInterner.intern(SimpleStringInterner.java:54)
    	org.apache.lucene.util.StringHelper.intern(StringHelper.java:36)
    	org.apache.lucene.index.Term.<init>(Term.java:38)
    	org.apache.lucene.queryParser.QueryParser.getPrefixQuery(QueryParser.java:1020)
    	org.apache.lucene.queryParser.QueryParser.Term(QueryParser.java:1408)
    	org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:1309)
    	org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:1266)
    	org.apache.lucene.queryParser.QueryParser.TopLevelQuery(QueryParser.java:1226)
    	org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:206)
    	org.neo4j.index.impl.lucene.IndexType.query(IndexType.java:281)
    [...]
    	org.neo4j.cypher.internal.pipes.StartPipe$$anonfun$createResults$1.apply(StartPipe.scala:35)
    	scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:200)
    [...]
    	scala.collection.immutable.List.flatMap(List.scala:45)
    	org.neo4j.cypher.internal.pipes.StartPipe.createResults(StartPipe.scala:35)
    [...]
    	org.neo4j.cypher.javacompat.ExecutionEngine.execute(ExecutionEngine.java:78)
    	org.springframework.data.neo4j.support.query.CypherQueryEngine.parseAndExecuteQuery(CypherQueryEngine.java:63)
    	org.springframework.data.neo4j.support.query.CypherQueryEngine.query(CypherQueryEngine.java:52)
    	org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.dispatchQuery(GraphRepositoryQuery.java:87)
    	org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:70)
    	org.springframework.data.neo4j.repository.query.DerivedCypherRepositoryQuery.execute(DerivedCypherRepositoryQuery.java:34)
    	org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:301)
    	org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    	org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)
    	org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    	$Proxy41.findByEntityIdLike(Unknown Source)
    	sun.reflect.GeneratedMethodAccessor64.invoke(Unknown Source)
    	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	java.lang.reflect.Method.invoke(Method.java:616)
    	org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
    	org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196)
    	$Proxy43.findByEntityIdLike(Unknown Source)
    	com.erpguru.ekpguru.services.SimpleDatabasePopulator.findEagerCustomersWithEntityIdLike(SimpleDatabasePopulator.java:1981)
    	com.erpguru.ekpguru.services.SimpleDatabasePopulator$$FastClassByCGLIB$$d30dabbb.invoke(<generated>)
    	net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
    	org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688)
    	org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    	org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    	org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)
    	com.erpguru.ekpguru.services.SimpleDatabasePopulator$$EnhancerByCGLIB$$70bbe370.findEagerCustomersWithEntityIdLike(<generated>)
    	com.erpguru.ekpguru.controller.EKPGuruController.performSearch(EKPGuruController.java:103)
    	sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source)
    	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	java.lang.reflect.Method.invoke(Method.java:616)
    	org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
    	org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
    	org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
    	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
    	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
    	org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:585)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:369)
    	org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
    	org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    	org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    	org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    	org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    	org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    	org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    	org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:177)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    	org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter.doFilter(DefaultLoginPageGeneratingFilter.java:91)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    	org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    	org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    	org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
    	org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
    	org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:168)
    	org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
    	org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
    Is this a defect, or should some characters like the space be escaped?

    Thanks,
    Daniel

  • #2
    After some investigation, and after learning basics of Cypher, this works:

    Code:
    start `simpleCustomer`=node:`search`("entityId:microsoft") return `simpleCustomer` skip 0 limit 5
    But this returns null (not an empty node.. it prints null on the screen):

    Code:
    start `simpleCustomer`=node:`search`("entityId:microsoft corporation") return `simpleCustomer` skip 0 limit 5
    (I hope we can escape the space!) Any thoughts?

    Thank you,
    Daniel

    Comment


    • #3
      By changing quotes like that, this will work, although it won't support wildcard operations:

      Code:
      start `simpleCustomer`=node:`search`('entityId:"microsoft corporation"') return `simpleCustomer` skip 0 limit 5

      Based on these observations:

      Code:
      microsoft                : works as expected
      *icros*                  : works as expected
      "microsoft"              : works because the word is complete
      "*icros*"                : doesn't return any result
      microsoft corporation    : boom
      "microsoft corporation"  : works because the phrase is complete
      "microsoft co*"          : doesn't return any result

      I will temporary enclose the phrase in quotes if and only if it contains a space (loosing wildcard operation, but the app won't crash)

      Comment


      • #4
        We have actually been discussing this in a couple of threads too.

        http://forum.springsource.org/showth...at-have-spaces

        and

        https://groups.google.com/group/neo4…f47770f7b17e09

        with a Jira ticket created

        https://jira.springsource.org/browse/DATAGRAPH-192

        Hope that helps. But looks like you are seeing the work-arounds and what can be done.

        Mark

        Comment

        Working...
        X