Problems with jo4neo-persistence.

56 views
Skip to first unread message

Stefan Berndt

unread,
Jun 14, 2010, 9:21:07 AM6/14/10
to jo4neo
Hi,

I'm really new to this persisting framework and have the first problem
by writing a simple test.

here my bean-class:

import jo4neo.Nodeid;
import jo4neo.neo;
import java.util.ArrayList;
import java.util.Collection;


public class Person {

transient Nodeid node;
@neo
String name;
@neo("FRIEND")
Collection<Person> friends=new ArrayList<Person>();

public Person(String name) {
this.name=name;
}

public void addFriend(Person person) {
friends.add(person);
}
}

and my testclass:

package guice;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.kernel.EmbeddedGraphDatabase;

public class PersonTest {
GraphDatabaseService ds;
@Before
public void setup() {
ds = new EmbeddedGraphDatabase("jo4neo_test/db");

}

@Test
public void someFriends() {
Person a = new Person("Tina");
Person b = new Person("Sarah");
a.addFriend(b);
}

@After
public void tearDown() {
ds.shutdown();
}
}

The Problem is, that after passing the test no object or Relationship
was made persistent in the graph.
Unfortunately there is no more detailed tutorial for jo4neo.
Maybe you can give me some hints. Thank you a lot!

Peter Neubauer

unread,
Jun 14, 2010, 9:34:19 AM6/14/10
to jo4...@googlegroups.com
Stefan,
it seems you shoudl make sure you call the graph.persist() method in
order to save changes, see
http://code.google.com/p/jo4neo/source/browse/trunk/patterns/userroles/src/main/java/example/Main.java
for an example.

Does that help?

Cheers,

/peter neubauer

COO and Sales, Neo Technology

GTalk: neubauer.peter
Skype peter.neubauer
Phone +46 704 106975
LinkedIn http://www.linkedin.com/in/neubauer
Twitter http://twitter.com/peterneubauer

http://www.neo4j.org - Your high performance graph database.
http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party.

Stefan Berndt

unread,
Jun 14, 2010, 9:54:25 AM6/14/10
to jo4neo
Peter, thx for you fast help!

Ok I've changed my testCase to that:

package guice;

import jo4neo.ObjectGraph;
import jo4neo.ObjectGraphFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.kernel.EmbeddedGraphDatabase;

public class PersonTest {
GraphDatabaseService ds;
ObjectGraph graph;
@Before
public void setup() {
ds = new EmbeddedGraphDatabase("jo4neo_test/db");
graph = ObjectGraphFactory.instance().get(ds);


}

@Test @DbTransactional
public void someFriends() {
Person a = new Person("Tina");
Person b = new Person("Sarah");
a.addFriend(b);
graph.persist(a, b);
graph.close();
}

@After
public void tearDown() {
ds.shutdown();
}
}

Now i get a NoClassDefError Exception:

java.lang.NoClassDefFoundError: org/neo4j/index/IndexService
at jo4neo.impl.ObjectGraphImpl.<init>(ObjectGraphImpl.java:29)
at jo4neo.impl.ObjectGraphProvider.create(ObjectGraphProvider.java:
10)
at jo4neo.ObjectGraphFactory.get(ObjectGraphFactory.java:36)
at guice.PersonTest.setup(PersonTest.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at org.junit.runners.model.FrameworkMethod
$1.runReflectiveCall(FrameworkMethod.java:44)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:
15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:
41)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:
27)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:
31)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:
70)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:
44)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:
28)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:
31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.junit.runner.JUnitCore.run(JUnitCore.java:159)
at
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:
94)
at
com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:
192)
at
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:
64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:
110)
Caused by: java.lang.ClassNotFoundException:
org.neo4j.index.IndexService
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 30 more

I dont know whats going wrong there. Maybe you can help me.


On 14 Jun., 15:34, Peter Neubauer <peter.neuba...@neotechnology.com>
wrote:
> Stefan,
> it seems you shoudl make sure you call the graph.persist() method in
> order to save changes, seehttp://code.google.com/p/jo4neo/source/browse/trunk/patterns/userrole...
> for an example.
>
> Does that help?
>
> Cheers,
>
> /peter neubauer
>
> COO and Sales, Neo Technology
>
> GTalk:      neubauer.peter
> Skype       peter.neubauer
> Phone       +46 704 106975
> LinkedIn  http://www.linkedin.com/in/neubauer
> Twitter      http://twitter.com/peterneubauer
>
> http://www.neo4j.org              - Your high performance graph database.http://www.thoughtmade.com- Scandinavia's coolest Bring-a-Thing party.
>
> On Mon, Jun 14, 2010 at 3:21 PM, Stefan Berndt
>

Peter Neubauer

unread,
Jun 14, 2010, 10:02:50 AM6/14/10
to jo4...@googlegroups.com
Stefan,
not sure what your classpath looks like and how you are running this.
Maven or plain Eclipse project?

In any case, this error is due to the missing Neo4j-Index component, so,
if you are maven, include not only the neo4j-kernel but even the
neo4j-index component, similar to
http://code.google.com/p/jo4neo/source/browse/trunk/jo4neo/pom.xml

If you are using plain java, download the Neo4j APOC distribution from
http://wiki.neo4j.org/content/Getting_Started_With_Apoc#Using_a_downloaded_zip.2Ftarball
and include the extracted libs (the index component and Apache Lucene
is among them) into your Java classpath for your project (e.g. in
Eclipse)

Does that help?

Cheers,

/peter neubauer

COO and Sales, Neo Technology

GTalk: neubauer.peter
Skype peter.neubauer
Phone +46 704 106975
LinkedIn http://www.linkedin.com/in/neubauer
Twitter http://twitter.com/peterneubauer

http://www.neo4j.org - Your high performance graph database.

http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party.

Stefan Berndt

unread,
Jun 14, 2010, 11:09:52 AM6/14/10
to jo4neo
Peter thanks for your help. in my pom was no entry for the index
dependency.
now it works and i have to try it out more for my issues. Thx for your
help a lot.

With kind regards,

stefan berndt


On 14 Jun., 16:02, Peter Neubauer <peter.neuba...@neotechnology.com>
wrote:
> Stefan,
> not sure what your classpath looks like and how you are running this.
> Maven or plain Eclipse project?
>
> In any case, this error is due to the missing Neo4j-Index component, so,
> if you are maven, include not only the neo4j-kernel but even the
> neo4j-index component, similar tohttp://code.google.com/p/jo4neo/source/browse/trunk/jo4neo/pom.xml
>
> If you are using plain java, download the Neo4j APOC distribution fromhttp://wiki.neo4j.org/content/Getting_Started_With_Apoc#Using_a_downl...
> and include the extracted libs (the index component and Apache Lucene
> is among them) into your Java classpath for your project (e.g. in
> Eclipse)
>
> Does that help?
>
> Cheers,
>
> /peter neubauer
>
> COO and Sales, Neo Technology
>
> GTalk:      neubauer.peter
> Skype       peter.neubauer
> Phone       +46 704 106975
> LinkedIn  http://www.linkedin.com/in/neubauer
> Twitter      http://twitter.com/peterneubauer
>
> http://www.neo4j.org              - Your high performance graph database.http://www.thoughtmade.com- Scandinavia's coolest Bring-a-Thing party.
>
> On Mon, Jun 14, 2010 at 3:54 PM, Stefan Berndt
> >>http://www.neo4j.org             - Your high performance graph database.http://www.thoughtmade.com-Scandinavia's coolest Bring-a-Thing party.

Taylor Cowan

unread,
Jun 14, 2010, 2:09:43 PM6/14/10
to jo4...@googlegroups.com
Here's jo4neo's POM:
http://code.google.com/p/jo4neo/source/browse/trunk/repo/thewebsemantic/jo4neo/0.4.1/jo4neo-0.4.1.pom

When you depend on jo4neo, it should pull in the index for you. Now
that you have the persistence working, there are many tests and some
demo apps that should also be helpful.

Taylor

Stefan Berndt

unread,
Jun 15, 2010, 6:04:42 AM6/15/10
to jo4neo
Thx for your help. My simple example works but i have to learn moreand
more what the framework does and how i can use it. thatswhy i have
tried to run your example here:

to see what happens in the graph and to play with it. but i get the
following exception:

15.06.2010 11:40:17
org.neo4j.kernel.impl.transaction.xaframework.XaLogicalLog
doInternalRecovery
INFO: Non clean shutdown detected on log [neo_store2/
nioneo_logical.log.1]. Recovery started ...
Exception in thread "main" java.lang.NoClassDefFoundError: org/neo4j/
index/IndexService
at jo4neo.impl.ObjectGraphImpl.<init>(ObjectGraphImpl.java:29)
at jo4neo.impl.ObjectGraphProvider.create(ObjectGraphProvider.java:
10)
at jo4neo.ObjectGraphFactory.get(ObjectGraphFactory.java:36)
at jo4neo_example.Main.main(Main.java:60)
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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:
110)
Caused by: java.lang.ClassNotFoundException:
org.neo4j.index.IndexService
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 9 more

but i do have neo-index in my repo and it's jarfiles are also in the
local maven repo:

<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-index</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>

Hope you can help me there. Thank you a lot!

Best regards,

Stefan



Stefan Berndt

unread,
Jun 15, 2010, 6:32:19 AM6/15/10
to jo4neo
Sorrry the first Exception in the post before was with neo4j-index
(1.0-b1-SNAPSHOT)

with neo4j-index (1.1-SNAPSHOT) this exception occurs:

Exception in thread "main" java.lang.NoSuchMethodError:
org.neo4j.commons.iterator.IteratorUtil.asIterable(Ljava/util/
Iterator;)Ljava/lang/Iterable;
at
org.neo4j.index.lucene.LuceneIndexService.getNodes(LuceneIndexService.java:
337)
at
org.neo4j.index.lucene.LuceneIndexService.getSingleNode(LuceneIndexService.java:
446)
at
org.neo4j.index.lucene.LuceneIndexService.getSingleNode(LuceneIndexService.java:
438)
at jo4neo.impl.LoadOperation.load(LoadOperation.java:312)
at jo4neo.impl.ObjectGraphImpl.getSingle(ObjectGraphImpl.java:124)
at jo4neo.impl.ResultImpl.result(ResultImpl.java:26)
at jo4neo_example.Main.main(Main.java:64)

Peter Neubauer

unread,
Jun 15, 2010, 6:33:27 AM6/15/10
to jo4...@googlegroups.com
Stefan,
are you sure you are running even 1.1-SNAPSHOT of the kernel
component, too? The commons package has been moved into the core neo4j
kernel ...

Cheers,

/peter neubauer

COO and Sales, Neo Technology

GTalk: neubauer.peter
Skype peter.neubauer
Phone +46 704 106975
LinkedIn http://www.linkedin.com/in/neubauer
Twitter http://twitter.com/peterneubauer

http://www.neo4j.org - Your high performance graph database.

http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party.

Taylor Cowan

unread,
Jun 15, 2010, 10:13:06 AM6/15/10
to jo4...@googlegroups.com
Stefan,

Sorry we're having some technical difficulties. The easiest thing to
do getting started is add this to your pom


<dependencies>
<dependency>
<groupId>thewebsemantic</groupId>
<artifactId>jo4neo</artifactId>
<version>0.4.2</version>
</dependency>
</dependencies>

0.4.2 is the latest version. Then point to the repo in googlecode...

<repositories>
<repository>
<id>googlecode</id>
<url>http://jo4neo.googlecode.com/svn/trunk/repo</url>
</repository>
</repositories>

The jo4neo dependency will then seek out it's dependencies on neoj4.
I hope that gets you going again.

Peter, can you point me to some guidance on finding a public maven
repo? I think it's time to put this someplace where it can be found
without too much trouble.

Taylor

Peter Neubauer

unread,
Jun 15, 2010, 10:20:10 AM6/15/10
to jo4...@googlegroups.com
Taylor,
I can start building jo4neo on http://buildbox.neo4j.org/hudson/ and
add deployment information to the pom.xml in order to automatically
deploy artifacts to http://m2.neo4j.org/ . We are currently working on
getting the artifacts onto our own proper Nexus repository, and
possibly propagated to the central maven repo, and could take jo4neo
along there?

Cheers,

/peter neubauer

COO and Sales, Neo Technology

GTalk: neubauer.peter
Skype peter.neubauer
Phone +46 704 106975
LinkedIn http://www.linkedin.com/in/neubauer
Twitter http://twitter.com/peterneubauer

http://www.neo4j.org - Your high performance graph database.

http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party.

Peter Neubauer

unread,
Jun 15, 2010, 10:33:22 AM6/15/10
to jo4...@googlegroups.com
http://buildbox.neo4j.org/hudson/job/jo4neo/ is building now.

Cheers,

/peter neubauer

COO and Sales, Neo Technology

GTalk: neubauer.peter
Skype peter.neubauer
Phone +46 704 106975
LinkedIn http://www.linkedin.com/in/neubauer
Twitter http://twitter.com/peterneubauer

http://www.neo4j.org - Your high performance graph database.
http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party.

Taylor Cowan

unread,
Jun 15, 2010, 12:00:39 PM6/15/10
to jo4...@googlegroups.com
Yes, i like it!

Sent from my HTC

Cheers,

/peter neubauer


[The entire original message is not included]

Reply all
Reply to author
Forward
0 new messages