my neo4j server workings well, but my server restarted and neo4j not started
server : Ubuntu 13.10
jdk: oracle jdk
this is errors:
SEVERE:
org.neo4j.server.ServerStartupException: Starting Neo4j Server failed: Error starting org.neo4j.kernel.EmbeddedGraphDatabase, /var/lib/neo4j/data/graph.db
at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:209)
at org.neo4j.server.Bootstrapper.start(Bootstrapper.java:87)
at org.neo4j.server.Bootstrapper.main(Bootstrapper.java:50)
Caused by: java.lang.RuntimeException: Error starting org.neo4j.kernel.EmbeddedGraphDatabase, /var/lib/neo4j/data/graph.db
at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:333)
at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:63)
at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:92)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:198)
at org.neo4j.kernel.impl.recovery.StoreRecoverer.recover(StoreRecoverer.java:115)
at org.neo4j.server.preflight.PerformRecoveryIfNecessary.run(PerformRecoveryIfNecessary.java:59)
at org.neo4j.server.preflight.PreFlightTasks.run(PreFlightTasks.java:70)
at org.neo4j.server.AbstractNeoServer.runPreflightTasks(AbstractNeoServer.java:319)
at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:144)
... 2 more
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.extension.KernelExtensions#4b9de054' was successfully initialized, but failed to start. Please see attached cause exception.
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:504)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:115)
at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:310)
... 10 more
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.index.lucene.LuceneKernelExtension#5df0330b' was successfully initialized, but failed to start. Please see attached cause exception.
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:504)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:115)
at org.neo4j.kernel.extension.KernelExtensions.start(KernelExtensions.java:118)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:498)
... 12 more
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.index.impl.lucene.LuceneDataSource#3fc9dd8c' was successfully initialized, but failed to start. Please see attached cause exception.
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:504)
at org.neo4j.kernel.lifecycle.LifeSupport.bringToState(LifeSupport.java:411)
at org.neo4j.kernel.lifecycle.LifeSupport.add(LifeSupport.java:324)
at org.neo4j.kernel.impl.transaction.XaDataSourceManager.registerDataSource(XaDataSourceManager.java:236)
at org.neo4j.index.lucene.LuceneKernelExtension.start(LuceneKernelExtension.java:79)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:498)
... 15 more
Caused by: java.lang.NullPointerException
at org.neo4j.kernel.impl.index.IndexProviderStore.<init>(IndexProviderStore.java:66)
at org.neo4j.index.impl.lucene.LuceneDataSource.newIndexStore(LuceneDataSource.java:301)
at org.neo4j.index.impl.lucene.LuceneDataSource.start(LuceneDataSource.java:224)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:498)
... 20 more
Jan 20, 2014 1:02:28 PM org.neo4j.server.logging.Logger log
SEVERE: Failed to start Neo Server on port [7474]
I was previously facing this problem. Later I figured out few points that you need to make sure are properly handled.
Make sure to use one instance at a time if in embedded mode.
Register shutdown hook properly
See if the server is still not running indexing while you restart.
delete tm_tx_log.1 file from the neo4j-db folder and then restart.
Now first 3 are less probable causing your problem, so what I did that I caught the exception thrown then deleted the tm_tx_log.1 file and then initialized the service. Not fool proof but a work around.
public class GraphDB {
private static GraphDB graph = null;
private static final String DB_PATH = "target/neo4j-db";
private static GraphDatabaseService graphService = null;
protected GraphDB() {
try{
graphService = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH);
registerShutdownHook(graphService);
}catch(Exception e){
File file = new File(DB_PATH+"/tm_tx_log.1");
file.delete();
}
}
public static GraphDB getInstance() {
if (graph == null) {
graph = new GraphDB();
}
return graph;
}
public GraphDatabaseService getGraphDbService() {
return graphService;
}
public void clearDb() {
try {
// FileUtils.deleteRecursively();
File files = new File(DB_PATH);
for(File file : files.listFiles()){
FileDeleteStrategy.FORCE.delete(file);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public void shutDown() {
System.out.println();
System.out.println("Shutting down database ...");
graphService.shutdown();
}
private static void registerShutdownHook(final GraphDatabaseService graphDb) {
Runtime.getRuntime().addShutdownHook(new Thread() {
#Override
public void run() {
graphDb.shutdown();
}
});
}
}
And in your main section while calling handle the case when the graphService is null.
public static void main(String[] args) {
GraphDB graphDb = GraphDB.getInstance();
if(graphDb == null){
graphDb = GraphDB.getInstance();
}
}
Related
I have a test that pass on my local machine. Also its pass on GitHub Actions Pipeline. But on my Jenkins its failed.
My QuarkusTestResourceLifecycleManager
public class Initializer implements QuarkusTestResourceLifecycleManager {
private static final String MARIADB_VERSION = "10.5.16";
private MariaDBContainer mariaDBContainer;
private static final Logger LOGGER = Logger.getLogger(Initializer.class);
#Override
public Map<String, String> start() {
LOGGER.info("Starting MariaDB v"+MARIADB_VERSION+" Test container");
this.mariaDBContainer = new MariaDBContainer("mariadb:"+MARIADB_VERSION)
.withDatabaseName("test")
.withUsername("test")
.withPassword("test");
this.mariaDBContainer.start();
return configurationParamters();
}
private Map<String, String> configurationParamters() {
return Map.of(
"quarkus.datasource.url", mariaDBContainer.getJdbcUrl(),
"quarkus.datasource.username", mariaDBContainer.getUsername(),
"quarkus.datasource.password", mariaDBContainer.getPassword()
);
}
#Override
public void stop() {
LOGGER.info("Stopping MariaDB Test container");
if (this.mariaDBContainer != null) {
this.mariaDBContainer.stop();
}
}
}
And my Testclass
#QuarkusTest
#QuarkusTestResource(Initializer.class)
class AuthenticatedUserDtoResourceTest {
#Inject
UserService userService;
#Test
void createUser() {
userService.createDummyUser();
Jenkins Logs
AuthenticatedUserDtoResourceTest > initializationError FAILED
java.lang.RuntimeException at QuarkusTestExtension.java:698
Caused by: java.lang.reflect.InvocationTargetException at DirectMethodHandleAccessor.java:119
Caused by: java.util.concurrent.CompletionException at CompletableFuture.java:315
Caused by: java.lang.RuntimeException at TestResourceManager.java:467
Caused by: java.lang.IllegalStateException at RyukResourceReaper.java:132
My Jenkins runs inside a Docker Container, I think because of that and the fact that my Testcontainer DB is also a Docker Container, some crazy Docker in Docker staff happens.
Any Idea how to solve it?
I am trying to get all the roles assigned to user when user logs in, using the code below.
public class roles extends AsyncTask <String,Void,Void>{
#Override
protected Void doInBackground(String... params) {
final CloudUser user = new CloudUser();
final CloudRole role = new CloudRole("MCA");
user.setUserName(params[0]);
user.setPassword(params[1]);
try {
user.logIn(new CloudUserCallback() {
#Override
public void done(CloudUser cloudUser, CloudException e) throws CloudException {
if (cloudUser != null) {
System.out.println("login Successful");
System.out.println(cloudUser.getUserName());
cloudUser.isInRole(role);
}
if (e != null) {
System.out.println("In logn exception");
e.printStackTrace();
}
}
});
} catch (CloudException e) {
e.printStackTrace();
}
return null;
}
}
I am getting the following error:
FATAL EXCEPTION: AsyncTask #1
Process: com.rakesh_kr.image, PID: 31256
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.ClassCastException: io.cloudboost.json.JSONArray cannot be cast to java.util.ArrayList
at io.cloudboost.CloudUser.isInRole(CloudUser.java:335)
at com.rakesh_kr.image.MainActivity$roles$1.done(MainActivity.java:174)
at io.cloudboost.CloudUser.logIn(CloudUser.java:219)
at com.rakesh_kr.image.MainActivity$roles.doInBackground(MainActivity.java:168)
at com.rakesh_kr.image.MainActivity$roles.doInBackground(MainActivity.java:155)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
This is a bug that occured in versions of CloudBoost JavaSDK prior to v1.0.7, this has been fixed, please clone the latest sources from github or get the latest jar(1.0.7) which should be available on maven in a few hours from now.
I am trying to connect embedded server but always getting
Caused by: java.io.IOException: Unable to lock org.neo4j.kernel.impl.nioneo.store.StoreFileChannel#5ceccc52
This is my configuration file.
#Configuration
#EnableNeo4jRepositories
public class Neo4jConfig extends Neo4jConfiguration {
public static final Setting<Boolean> remote_shell_enabled = Settings.setting("remote_shell_enabled", Settings.BOOLEAN, Settings.TRUE);
public static final Setting<Boolean> enable_remote_shell = Settings.setting("enable_remote_shell", Settings.BOOLEAN, Settings.TRUE);
public Neo4jConfig() {
setBasePackage("com.repo", "com.model");
}
#Bean
GraphDatabaseService graphDatabaseService() {
return new GraphDatabaseFactory()
.newEmbeddedDatabaseBuilder("neo.db2")
.setConfig(enable_remote_shell, "true")
.newGraphDatabase();
}
}
How are you trying to connect the shell?
Just do:
bin/neo4j-shell
No -path parameter !! As then you would start a new database on the same directory.
I am using Neo4j 1.8.2 with spatial 0.9.
I get the following exception when I try to get a handle to the spatial index on an existing graph that contains the index already:
Exception in thread "main" java.lang.IllegalArgumentException: Supplied index configuration:
{geometry_type=point, lon=lon, provider=spatial, lat=lat}
doesn't match stored config in a valid way:
{geometry_type=point, lon=lon, provider=spatial, lat=lat}
for 'testspatial'
at org.neo4j.kernel.IndexManagerImpl.assertConfigMatches(IndexManagerImpl.java:156)
at org.neo4j.kernel.IndexManagerImpl.findIndexConfig(IndexManagerImpl.java:137)
at org.neo4j.kernel.IndexManagerImpl.getOrCreateIndexConfig(IndexManagerImpl.java:198)
at org.neo4j.kernel.IndexManagerImpl.getOrCreateNodeIndex(IndexManagerImpl.java:301)
at org.neo4j.kernel.IndexManagerImpl.forNodes(IndexManagerImpl.java:289)
at TestSpatialIndexFetch.createSpatialIndex(TestSpatialIndexFetch.java:22)
at TestSpatialIndexFetch.main(TestSpatialIndexFetch.java:18)
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:120)
If I delete the database, the index is created successfully. If I use this database now to get the index back, it fails.
Any ideas?
Sample test code:
public class TestSpatialIndexFetch {
public static void main(String[] args) {
EmbeddedGraphDatabase db = new EmbeddedGraphDatabase("c://neo4jdbs//testindex");
registerShutdownHook(db);
Index<Node> index = createSpatialIndex(db, "testspatial");
}
private static Index<Node> createSpatialIndex(EmbeddedGraphDatabase db, String indexName) {
return db.index().forNodes(indexName, SpatialIndexProvider.SIMPLE_POINT_CONFIG);
}
private static void registerShutdownHook( final GraphDatabaseService graphDb )
{
Runtime.getRuntime().addShutdownHook( new Thread()
{
#Override
public void run()
{
graphDb.shutdown();
}
} );
}
}
Fixed and released at http://m2.neo4j.org/content/repositories/releases/org/neo4j/neo4j-spatial/0.9.1-neo4j-1.8.2/
Issue 93: https://github.com/neo4j/spatial/issues/93
I have copied and pasted a simple neo4j example from the tutorial section but currently i got the messages:
[INFO] Surefire report directory: /home/kama/ws-git/neo4jexample/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNGMapConfigurator#17bd6a1
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 2.995 sec <<< FAILURE!
Results :
Failed tests: firstTest(com.soebes.tutorials.Neo4JAppTest): com/soebes/tutorials/neo4jexample/RelationTypes
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
The detailed error message:
java.lang.NoClassDefFoundError: com/soebes/tutorials/neo4jexample/RelationTypes
at com.soebes.tutorials.neo4jexample.Neo4JApp.createDb(Neo4JApp.java:44)
at com.soebes.tutorials.neo4jexample.Neo4JApp.main(Neo4JApp.java:25)
at com.soebes.tutorials.Neo4JAppTest.firstTest(Neo4JAppTest.java:14)
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 org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:691)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:883)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1208)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:758)
at org.testng.TestRunner.run(TestRunner.java:613)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1137)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1062)
at org.testng.TestNG.run(TestNG.java:974)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:76)
at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeMulti(TestNGDirectoryTestSuite.java:161)
at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:101)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:115)
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 org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)
Caused by: java.lang.ClassNotFoundException: com.soebes.tutorials.neo4jexample.RelationTypes
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
The source code of this looks like this:
public class Neo4JApp {
private String greeting;
private GraphDatabaseService graphDb;
private Node firstNode;
private Node secondNode;
private Relationship relationship;
public static void main(final String[] args) {
Neo4JApp hello = new Neo4JApp();
hello.createDb(args[0]);
hello.removeData();
hello.shutDown();
}
void createDb(String path) {
clearDb(path);
graphDb = new EmbeddedGraphDatabase(path);
registerShutdownHook(graphDb);
Transaction tx = graphDb.beginTx();
try {
firstNode = graphDb.createNode();
firstNode.setProperty("message", "Hello, ");
secondNode = graphDb.createNode();
secondNode.setProperty("message", "World!");
relationship = firstNode.createRelationshipTo(secondNode, RelationTypes.KNOWS);
relationship.setProperty("message", "brave Neo4j ");
System.out.print(firstNode.getProperty("message"));
System.out.print(relationship.getProperty("message"));
System.out.print(secondNode.getProperty("message"));
greeting = ((String) firstNode.getProperty("message"))
+ ((String) relationship.getProperty("message"))
+ ((String) secondNode.getProperty("message"));
tx.success();
} finally {
tx.finish();
}
}
private void clearDb(String path) {
try {
FileUtils.deleteRecursively(new File(path));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
void removeData() {
Transaction tx = graphDb.beginTx();
try {
firstNode.getSingleRelationship(RelationTypes.KNOWS, Direction.OUTGOING).delete();
firstNode.delete();
secondNode.delete();
tx.success();
} finally {
tx.finish();
}
}
void shutDown() {
System.out.println();
System.out.println("Shutting down database ...");
graphDb.shutdown();
}
private static void registerShutdownHook(final GraphDatabaseService graphDb) {
// Registers a shutdown hook for the Neo4j instance 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() {
graphDb.shutdown();
}
});
}
And the used class RelationTypes looks like this:
public enum RelationTypes implements RelationshipType {
KNOWS,
WHOKNOWS,
}
The project can be found at github.
Currently i don't see the problem?...The RelationTypes are defined in the correct location...May be someone has a hint for me?
The problem was the directory of the unit test which is not allowed to be the target folder itself. It must be a separate folder under target.