Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-19-2019 09:39 PM
Hi, I am trying to connect java and neo4j (community version 3.5.9) on windows. I have pasted the code and the errors. Appreciate if you could help me out to fix this.
code:
package neo4jconnection;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.graphdb.Label;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.Node;
public class Main {
public enum NodeType implements Label{
Person,Course;}
public enum RelationType implements RelationshipType{
knows,BelongsTo;}
public static void main(String[] args) {
GraphDatabaseFactory dbFactory=new GraphDatabaseFactory();
GraphDatabaseService graphDb=dbFactory.newEmbeddedDatabase("C:\\Users\\Divya Jose\\Desktop\\neo4j-community-3.5.9-windows\\neo4j-community-3.5.9\\data\\databases\\graph.db");
try(Transaction tx=graphDb.beginTx())
{
Node bobNode=graphDb.createNode(NodeType.Person);
bobNode.setProperty("PId",5001);
bobNode.setProperty("Name","Bob");
bobNode.setProperty("Age",23);
Node aliceNode=graphDb.createNode(NodeType.Person);
aliceNode.setProperty("PId",5002);
aliceNode.setProperty("Name","Alice");
aliceNode.setProperty("Age",23);
Node eveNode=graphDb.createNode(NodeType.Person);
eveNode.setProperty("PId",5003);
eveNode.setProperty("Name","Eve");
eveNode.setProperty("Age",23);
Node itNode=graphDb.createNode(NodeType.Course);
itNode.setProperty("Id",1);
itNode.setProperty("Name","It Beginners");
itNode.setProperty("Location","Room 123");
Node electroNode=graphDb.createNode(NodeType.Course);
electroNode.setProperty("Id",2);
electroNode.setProperty("Name","Electronic Beginners");
electroNode.setProperty("Location","Room 223");
bobNode.createRelationshipTo(aliceNode, RelationType.knows);
//bobNode.createRelationshipTo(aliceNode, RelationType.knows);
Relationship bobRelIt=bobNode.createRelationshipTo(itNode, RelationType.BelongsTo);
bobRelIt.setProperty("Function","Student");
Relationship bobRelElectronics=bobNode.createRelationshipTo(itNode, RelationType.BelongsTo);
bobRelIt.setProperty("Function","Supply Teacher");
Relationship aliceRelIt=aliceNode.createRelationshipTo(itNode, RelationType.BelongsTo);
bobRelIt.setProperty("Function","Teacher");
tx.success();
}
graphDb.shutdown();
}
}
I am getting the below errors:
Exception in thread "main" java.lang.RuntimeException: Error starting org.neo4j.kernel.EmbeddedGraphDatabase, C:\Users\Divya Jose\Desktop\neo4j-community-3.5.9-windows\neo4j-community-3.5.9\data\databases\graph.db
at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:366)
at org.neo4j.kernel.EmbeddedGraphDatabase.(EmbeddedGraphDatabase.java:59)
at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:91)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:181)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:71)
at neo4jconnection.Main.main(Main.java:20)
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.impl.transaction.XaDataSourceManager@70beb599' was successfully initialized, but failed to start. Please see attached cause exception.
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:513)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:115)
at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:343)
... 5 more
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.impl.nioneo.xa.NeoStoreXaDataSource@11c20519' was successfully initialized, but failed to start. Please see attached cause exception.
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:513)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:115)
at org.neo4j.kernel.impl.transaction.XaDataSourceManager.start(XaDataSourceManager.java:164)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:507)
... 7 more
Caused by: org.neo4j.kernel.impl.storemigration.StoreUpgrader$UpgradingStoreVersionNotFoundException: 'neostore.nodestore.db' does not contain a store version, please ensure that the original database was shut down in a clean state.
at org.neo4j.kernel.impl.storemigration.UpgradableDatabase.checkUpgradeable(UpgradableDatabase.java:78)
at org.neo4j.kernel.impl.storemigration.StoreMigrator.needsMigration(StoreMigrator.java:135)
at org.neo4j.kernel.impl.storemigration.StoreUpgrader.getParticipantsEagerToMigrate(StoreUpgrader.java:268)
at org.neo4j.kernel.impl.storemigration.StoreUpgrader.migrateIfNeeded(StoreUpgrader.java:143)
at org.neo4j.kernel.impl.nioneo.xa.NeoStoreXaDataSource.start(NeoStoreXaDataSource.java:344)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:507)
... 10 more
In the config file I have uncommented
dbms.active_database=graph.db
dbms.allow_upgrade=true
09-20-2019 12:01 PM
It sounds like you're either trying to upgrade a very outdated graph.db
, or (like it says) it has been somehow corrupted. That's just a literal interpretation of what the error is telling you, but I'm not sure what level of neo4j experience you're coming in with. If you are starting with a fresh installation, and have not interacted with the graph.db
file folder, then it's something else. Presumably you are not just having problems connecting from your app, but also from Neo4j Desktop? When you run neo4j console
, this is the raw server starting up, I would start debugging from there versus trying to do it via your app, which adds another layer of potential issues.
All the sessions of the conference are now available online