[Neo4J 1.9.05 / SDN 2.2.0] Missing index exception while loading Repositories through Spring

144 views
Skip to first unread message

Michael Azerhad

unread,
May 16, 2013, 6:38:17 PM5/16/13
to ne...@googlegroups.com
Hello,

I have this repository:

trait UserRepository extends GraphRepository[User] {


 
@Query("start u=node:User(_userName = {0}) return u")
 
def findByUserName(userName: String): User


 
@Query("start up=node:UserProfile(_email = {0}) match (up)<-- (u) return u")
 
def findByEmail(email: String): User


 
@Query("start u=node:User(_id = {0}) return u")
 
def findByUuid(uuid: String): User
}


My test database (ImpermanentGraphDatabase) is actually empty.

Thus, I launch a test aiming to test this repository.

However, it complains about this error:

org.springframework.dao.InvalidDataAccessResourceUsageException: Error executing statement start u=node:User(_id = {0}) return u; nested exception is org.neo4j.cypher.MissingIndexException: Index `User` does not exist

My User entity is declared as this:

@NodeEntity
final class User  ...


By reading some docs about this issue, it seems that at least one User node must be added in order to create the User Index, and BEFORE using my cypher query.

Is it true? Do i have to deal with node_auto_index?

How should I fix it?

Thanks a lot.

Peter Neubauer

unread,
May 16, 2013, 7:48:13 PM5/16/13
to Neo4j User
Michaël,
yes, this is a limitation of Cypher in Neo4j 1.9, not supporting index
creation. This is no longer present in Cypher 2.0 with Labels , and
will thus disappear shortly.

For the time being, it might be a good idea to create a dummy user as
part of your setup before using the repository methods. Woudl that
work?

/peter

Cheers,

/peter neubauer

G: neubauer.peter
S: peter.neubauer
P: +46 704 106975
L: http://www.linkedin.com/in/neubauer
T: @peterneubauer

The authoritative book on graph databases - http://graphdatabases.com
Neo4j questions? Please use SO - http://stackoverflow.com/search?q=neo4j
> --
> You received this message because you are subscribed to the Google Groups
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to neo4j+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Michael Azerhad

unread,
May 16, 2013, 8:10:08 PM5/16/13
to ne...@googlegroups.com
Hi Peter,

I came across some strange behaviors for one week : 
Once, my test dealing with some Indexes passes, other times it doesn't ...complaining about Missing Index Error.

Now, thanks to your answer, I understand both reasons explaining this "random" :

  1. Specs2 (test framework I use working with Scala) by default executes test in a random order. When some test tries to "find" a User before having added one, it fails. Thus, test order is important in this case.  => First saving a user, then this one is findable using Index.
  2. Not all my tests add some dummy User BEFORE trying to "find" anyone through Cypher.    
Solution I chose:  Adding a dummy User like you advises BEFORE each test needing some Neo4j queries, especially "find" queries.
                          Letting the multi-threaded aspect from Specs2, meaning order does not matter any more.

Thank you Peter for your quickness and your answer :)

Cheers,

Michael

Peter Neubauer

unread,
May 17, 2013, 1:39:26 AM5/17/13
to Neo4j User
Nice you solved it Michael,
sorry for the workaround for the time being - it will get better in Neo4j 2.0!

/peter

Cheers,

/peter neubauer

G: neubauer.peter
S: peter.neubauer
P: +46 704 106975
L: http://www.linkedin.com/in/neubauer
T: @peterneubauer

The authoritative book on graph databases - http://graphdatabases.com
Neo4j questions? Please use SO - http://stackoverflow.com/search?q=neo4j


On Thu, May 16, 2013 at 5:10 PM, Michael Azerhad

Duane Nickull

unread,
May 17, 2013, 2:28:31 PM5/17/13
to ne...@googlegroups.com
When: Monday May 20, 2013

Where: Vancouver, BC

What: Neo4J co-founder Peter Neubauer will be returning to Vancouver. The
abstract of his talk will be send soon.

With the first Milestones of the Neo4j 2.0 series which we expect to be
generally available (GA) in the next couple months. This release is
significant in that it is the first time since the inception of Neo4j
thirteen years ago that we are making a change to the property graph
model. Specifically, we will be adding a new construct: labels.
Peter will go through some of the major features, Cypher changes,
Transactional REST enpoints and other goodies.

We are looking for one future speakers. Please use the form located at
https://whis.pr/o/13643279992744c72b931ffffe04d1/f/13680315565594c72b931fff
fe04d1/fill


We will also be presenting a small case study of Whis.pr (http://whis.pr).
Whispr is powered by Neo4J and some of the reasons and developer benefits
will be revealed at the User Group meeting.

There are no plans to record it but if there is interest, we can bring a
camera and post a video later.

Duane Nickull

***********************************
Technoracle Advanced Systems Inc.
Consulting and Contracting; Proven Results!
i. Neo4J, PDF, Java, LiveCycle ES, Flex, AIR, CQ5 & Mobile
b. http://technoracle.blogspot.com
t. @duanenickull


NOTICE: This e-mail and any attachments may contain confidential
information. If you are the intended recipient, please consider this a
privileged communication, not to be forwarded without explicit approval
from the sender. If you are not the intended recipient, please notify the
sender immediately by return e-mail, delete this e-mail and destroy any
copies. Any dissemination or use of this information by a person other
than the intended recipient is unauthorized and may be illegal. The
originator reserves the right to monitor all e-mail communications through
its networks for quality control purposes.

michael azerhad

unread,
May 17, 2013, 2:33:24 PM5/17/13
to ne...@googlegroups.com
It would be great if Peter's talk could be recorded and posted as a video :)

Michaël Azerhad (French Neo4j user)

Peter Neubauer

unread,
May 18, 2013, 4:17:56 AM5/18/13
to Neo4j User
Yeah,
at the least we will try to put up a phone video with Bambuser. Let's
see how that works out! We will then post the link here, ok?

/peter

Cheers,

/peter neubauer

G: neubauer.peter
S: peter.neubauer
P: +46 704 106975
L: http://www.linkedin.com/in/neubauer
T: @peterneubauer

The authoritative book on graph databases - http://graphdatabases.com
Neo4j questions? Please use SO - http://stackoverflow.com/search?q=neo4j


Michael Hunger

unread,
May 18, 2013, 4:20:34 AM5/18/13
to ne...@googlegroups.com
This shouldn't happen as there is a special listener that checks/creates indexes for each registered entity class.

Can you share your config too?

Michael

Michael Hunger

unread,
May 18, 2013, 4:21:05 AM5/18/13
to ne...@googlegroups.com
That's not true, SDN handles this case on its own.

Michael

michael azerhad

unread,
May 18, 2013, 4:45:33 PM5/18/13
to ne...@googlegroups.com
Would be Perfect :)

Michael
> You received this message because you are subscribed to a topic in the Google Groups "Neo4j" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/neo4j/67n5OiMOqps/unsubscribe?hl=en.
> To unsubscribe from this group and all its topics, send an email to neo4j+un...@googlegroups.com.

Michael Azerhad

unread,
May 18, 2013, 5:43:25 PM5/18/13
to ne...@googlegroups.com
Hi Michael,

Here's interesting part of my project configuration (using SBT to manage dependencies):

"org.springframework" % "spring-aop" % "3.2.0.RELEASE",
    "org.springframework" % "spring-aspects" % "3.2.0.RELEASE",
    "org.springframework" % "spring-beans" % "3.2.0.RELEASE",
    "org.springframework" % "spring-expression" % "3.2.0.RELEASE",
    "org.springframework" % "spring-jdbc" % "3.2.0.RELEASE",
    "org.springframework" % "spring-orm" % "3.2.0.RELEASE",
    "org.springframework" % "spring-test" % "3.2.0.RELEASE",
    "org.springframework" % "spring-tx" % "3.2.0.RELEASE",
    "org.springframework.data" % "spring-data-neo4j" % "2.2.0.RELEASE" excludeAll(
      ExclusionRule(organization = "com.sun.jdmk"),
      ExclusionRule(organization = "com.sun.jmx"),
      ExclusionRule(organization = "javax.jms")
      ),
    "org.neo4j" % "neo4j" % "1.9.RC2" excludeAll (
      ExclusionRule(organization = "org.neo4j", name = "neo4j-kernel")
      ),
    "org.neo4j" % "neo4j-kernel" % "1.9.RC2" % "test" classifier "tests" classifier "",
    "org.ow2.asm" % "asm-all" % "4.0",
    "org.springframework.data" % "spring-data-neo4j-rest" % "2.2.0.RELEASE" excludeAll (
      ExclusionRule(organization = "org.neo4j")
      ),
    "org.neo4j" % "neo4j-rest-graphdb" % "1.9.RC2"

Unable to handle index creation before saving the corresponding entity at least once in the graph.

Maybe this improvement comes with the 2.3.0 SNAPSHOT of SDN? I haven't tested it yet.

Thanks :)

Michael

Michael Hunger

unread,
May 18, 2013, 7:38:39 PM5/18/13
to ne...@googlegroups.com
This has been in there for some versions. Perhaps some change in sd-commons. Have to check that next week.

I meant the spring setup btw :)

Btw. you won't be happy using SDN over REST, this setup is not fast enough. We will be working on that as part of the Neo4j 2.0 upgrade which will move parts of SDN to work on top of cypher instead of the current, embedded API.

Cheers

Michael

Michael Azerhad

unread,
May 18, 2013, 7:55:48 PM5/18/13
to ne...@googlegroups.com
Ah yes, sorry :)  You expect my application-context.xml.  
It's this one:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       
xmlns:context="http://www.springframework.org/schema/context"
       
xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
       
xmlns:tx="http://www.springframework.org/schema/tx"
       
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/data/neo4j
       http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.2.xsd  http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"
>


   
<neo4j:config graphDatabaseService="graphDatabaseService"/>


   
<bean id="graphDatabaseService" class="org.neo4j.test.ImpermanentGraphDatabase" destroy-method="shutdown"/>


   
<tx:annotation-driven mode="aspectj" />


   
<neo4j:repositories base-package="com.myApp.domain.repositories"/>


   
<context:load-time-weaver/>


   
<context:annotation-config/>


   
<context:component-scan base-package="com.myApp.controllers, com.myApp.applicationservices, com.myApp.domain.repositories"/>


</beans>


As I am currently in development phase, performance is not so important for now. 

As we say in French, "Neo4j 2.0 va être une tuerie ! " ;)

Thanks a lot,

Michael
Reply all
Reply to author
Forward
0 new messages