neo4j/community — Issue #278: neo4j-utils - dependency - bug 
Author: Daidalos
Created: 2012-02-26 19:55:24+00:00
State: open

Hi,

there is an bug, if you use neo4j-utils - if not, everything is fine. I need the NodeWrapper from the util package. I did'nt found any other solution than this is a bug. Everyone in the internet had the same problems and often no solution.

This are dependancies.

org.neo4j
neo4j-kernel
1.6.1

org.neo4j
neo4j-lucene-index
1.6.1

org.neo4j
neo4j-utils
1.3-1.3.M01

If you leave the neo4j-utils it works fine.

Here an demo code - it from the neo4j startup pages.

import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.index.Index;
import org.neo4j.graphdb.index.IndexManager;
import org.neo4j.kernel.EmbeddedGraphDatabase;

public class Neo4jTest {
private static final String DB_PATH = "neo4j-store";
private static final String USERNAME_KEY = "username";
private static GraphDatabaseService graphDb;
private static Index nodeIndex;

// START SNIPPET: createRelTypes
private static enum RelTypes implements RelationshipType
{
USERS_REFERENCE,
USER
}
// END SNIPPET: createRelTypes

public static void main( final String[] args )
{
// START SNIPPET: startDb
graphDb = new EmbeddedGraphDatabase( DB_PATH );
final IndexManager index = graphDb.index();
nodeIndex = index.forNodes( "nodes" );
registerShutdownHook();
// END SNIPPET: startDb

// START SNIPPET: addUsers
Transaction tx = graphDb.beginTx();
try
{
// Create users sub reference node (see design guidelines on
// http://wiki.neo4j.org/ )
Node usersReferenceNode = graphDb.createNode();
graphDb.getReferenceNode().createRelationshipTo(
usersReferenceNode, RelTypes.USERS_REFERENCE );
// Create some users and index their names with the IndexService
for ( int id = 0; id < 100; id++ )
{
Node userNode = createAndIndexUser( idToUserName( id ) );
usersReferenceNode.createRelationshipTo( userNode,
RelTypes.USER );
}
// END SNIPPET: addUsers
System.out.println( "Users created" );

// Find a user through the search index
// START SNIPPET: findUser
int idToFind = 45;
Node foundUser = nodeIndex.get( USERNAME_KEY,
idToUserName( idToFind ) ).getSingle();
System.out.println( "The username of user " + idToFind + " is "
+ foundUser.getProperty( USERNAME_KEY ) );
// END SNIPPET: findUser

// Delete the persons and remove them from the index
for ( Relationship relationship : usersReferenceNode.getRelationships(
RelTypes.USER, Direction.OUTGOING ) )
{
Node user = relationship.getEndNode();
nodeIndex.remove( user, USERNAME_KEY,
user.getProperty( USERNAME_KEY ) );
user.delete();
relationship.delete();
}
usersReferenceNode.getSingleRelationship( RelTypes.USERS_REFERENCE,
Direction.INCOMING ).delete();
usersReferenceNode.delete();
tx.success();
}
finally
{
tx.finish();
}
System.out.println( "Shutting down database ..." );
shutdown();
}

private static void shutdown()
{
graphDb.shutdown();
}

// START SNIPPET: helperMethods
private static String idToUserName( final int id )
{
return "user" + id + "@neo4j.org";
}

private static Node createAndIndexUser( final String username )
{
Node node = graphDb.createNode();
node.setProperty( USERNAME_KEY, username );
nodeIndex.add( node, USERNAME_KEY, username );
return node;
}
// END SNIPPET: helperMethods

private static void registerShutdownHook()
{
// Registers a shutdown hook for the Neo4j and index service instances
// so that it shuts down nicely when the VM exits (even if you
// "Ctrl-C" the running example before it's completed)
Runtime.getRuntime().addShutdownHook( new Thread()
{
@Override
public void run()
{
shutdown();
}
} );
}
}

ErrorMessage

org.neo4j.graphdb.TransactionFailureException: Could not create data source lucene[lucene]
at org.neo4j.kernel.impl.transaction.TxModule.registerDataSource(TxModule.java:189)
at org.neo4j.kernel.GraphDbInstance.registerLuceneDataSource(GraphDbInstance.java:221)
at org.neo4j.kernel.GraphDbInstance.start(GraphDbInstance.java:117)
at org.neo4j.kernel.EmbeddedGraphDbImpl.(EmbeddedGraphDbImpl.java:190)
at org.neo4j.kernel.EmbeddedGraphDatabase.(EmbeddedGraphDatabase.java:77)
at org.neo4j.kernel.EmbeddedGraphDatabase.(EmbeddedGraphDatabase.java:61)
at neo4jtest.org.tingo.test.Neo4jTest.main(Neo4jTest.java:30)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.neo4j.kernel.impl.transaction.XaDataSourceManager.create(XaDataSourceManager.java:77)
at org.neo4j.kernel.impl.transaction.TxModule.registerDataSource(TxModule.java:183)
... 6 more
Caused by: java.lang.NoSuchMethodError: org.neo4j.kernel.impl.transaction.xaframework.XaContainer.create(Lorg/neo4j/kernel/impl/transaction/xaframework/XaDataSource;Ljava/lang/String;Lorg/neo4j/kernel/impl/transaction/xaframework/XaCommandFactory;Lorg/neo4j/kernel/impl/transaction/xaframework/XaTransactionFactory;Ljava/util/Map;)Lorg/neo4j/kernel/impl/transaction/xaframework/XaContainer;
at org.neo4j.index.lucene.LuceneDataSource.(LuceneDataSource.java:128)
... 12 more
Exception in thread "main" org.neo4j.graphdb.TransactionFailureException: Could not create data source lucene[lucene]
at org.neo4j.kernel.impl.transaction.TxModule.registerDataSource(TxModule.java:189)
at org.neo4j.kernel.GraphDbInstance.registerLuceneDataSource(GraphDbInstance.java:221)
at org.neo4j.kernel.GraphDbInstance.start(GraphDbInstance.java:117)
at org.neo4j.kernel.EmbeddedGraphDbImpl.(EmbeddedGraphDbImpl.java:190)
at org.neo4j.kernel.EmbeddedGraphDatabase.(EmbeddedGraphDatabase.java:77)
at org.neo4j.kernel.EmbeddedGraphDatabase.(EmbeddedGraphDatabase.java:61)
at neo4jtest.org.tingo.test.Neo4jTest.main(Neo4jTest.java:30)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.neo4j.kernel.impl.transaction.XaDataSourceManager.create(XaDataSourceManager.java:77)
at org.neo4j.kernel.impl.transaction.TxModule.registerDataSource(TxModule.java:183)
... 6 more
Caused by: java.lang.NoSuchMethodError: org.neo4j.kernel.impl.transaction.xaframework.XaContainer.create(Lorg/neo4j/kernel/impl/transaction/xaframework/XaDataSource;Ljava/lang/String;Lorg/neo4j/kernel/impl/transaction/xaframework/XaCommandFactory;Lorg/neo4j/kernel/impl/transaction/xaframework/XaTransactionFactory;Ljava/util/Map;)Lorg/neo4j/kernel/impl/transaction/xaframework/XaContainer;
at org.neo4j.index.lucene.LuceneDataSource.(LuceneDataSource.java:128)
... 12 more