Michael,

I did solve the problem - and it had nothing to do with the 
connecting-code. However, it was a fascinating issue:

In one of my methods I kept a Neo4j node object (of type org 
<eclipse-javadoc:%E2%98%82=ThesisPrototype/lib%5C/neo4j-desktop-2.1.2.jar%3Corg>
.neo4j 
<eclipse-javadoc:%E2%98%82=ThesisPrototype/lib%5C/neo4j-desktop-2.1.2.jar%3Corg.neo4j>
.graphdb 
<eclipse-javadoc:%E2%98%82=ThesisPrototype/lib%5C/neo4j-desktop-2.1.2.jar%3Corg.neo4j.graphdb>
.Node) in order to use it later for creating relationships.
When I now keep a node object of one seesion in my code, do a reconnect, 
and add another node object in order to make a relation, Neo4j will 
complain because the two node objects are from different connection 
sessions.

Fascinating, is'nt it? ;)

Anyhow, you gave me the idea that I need to look somewhere else in my code 
rather than in the connection code.

Thank you very much - Und viele liebe Grüße aus Österreich ;)

Markus

On Saturday, November 22, 2014 9:23:48 PM UTC+1, Michael Hunger wrote:
>
> This works perfect for me:
>
> GraphDatabaseService db = new 
> GraphDatabaseFactory().newEmbeddedDatabase("target/shutdown.db");
> Node node;
> try (Transaction tx = db.beginTx()) {
>     node = db.createNode();
>     System.out.println("node = " + node);
>     tx.success();
> }
> db.shutdown();
> db = new GraphDatabaseFactory().newEmbeddedDatabase("target/shutdown.db");
> try (Transaction tx = db.beginTx()) {
>     node = db.getNodeById(node.getId());
>     System.out.println("node = " + node);
>     tx.success();
> }
> db.shutdown();
>
>
> On Sat, Nov 22, 2014 at 9:20 PM, Michael Hunger <
> [email protected] <javascript:>> wrote:
>
>> I meant you have to pause your processing in java if you want to access 
>> the db externally.
>>
>> On Sat, Nov 22, 2014 at 9:15 PM, Markus Gutmann <[email protected] 
>> <javascript:>> wrote:
>>
>>> I simply execute the connect-code I have posted above in order to 
>>> connect to the db.
>>>
>>> In this code I do reassign a new value to the variable _gdbService so I 
>>> am not quite sure whether _gdbService still points to the old db - I would 
>>> rather say no.
>>>
>>> What do you mean with "wait to continue" .. ? is there a certain time 
>>> threshold to wait?
>>>
>>> Even if I wait a few seconds (up to 1 minute) the result is the same ...
>>>
>>>
>>>
>>> On Saturday, November 22, 2014 9:09:04 PM UTC+1, Michael Hunger wrote:
>>>>
>>>> I think your _gdbService variable still refers to the old db-instance 
>>>> and was not set to the newly created instance.
>>>>
>>>> How do you wait to continue after you finished the external operation 
>>>> with the db?
>>>>
>>>> Could that be?
>>>>
>>>> Michael
>>>>
>>>> On Sat, Nov 22, 2014 at 8:59 PM, Markus Gutmann <[email protected]> 
>>>> wrote:
>>>>
>>>>> I do
>>>>>
>>>>> 1. connect
>>>>> 2. disconnect
>>>>> 3. connect
>>>>>
>>>>> as described in my original post.
>>>>>
>>>>> Then I execute the following method:
>>>>>
>>>>> try ( Transaction transaction = _gdbService.beginTx() ) {
>>>>>  
>>>>>  Iterable<Relationship> relationships = node.getRelationships(Directio
>>>>> n.OUTGOING);
>>>>> ...
>>>>>
>>>>>
>>>>> and the first line throws an exception with the following trace:
>>>>>
>>>>>  
>>>>> org.neo4j.graphdb.DatabaseShutdownException: This database is shutdown
>>>>> .
>>>>>  at org.neo4j.kernel.impl.core.ThreadToStatementContextBridge.ch
>>>>> eckIfShutdown(ThreadToStatementContextBridge.java:80)
>>>>>  at org.neo4j.kernel.impl.core.ThreadToStatementContextBridge.instance
>>>>> (ThreadToStatementContextBridge.java:54)
>>>>>  at org.neo4j.kernel.impl.core.NodeProxy.getRelationships(NodeProxy.
>>>>> java:140)
>>>>>  at org.neo4j.kernel.impl.core.NodeProxy.getRelationships(NodeProxy.
>>>>> java:76)
>>>>>  at thesisPrototype.cfgUtilizer.cfgdb.GraphDatabase.findAdjacent
>>>>> ReachableNode(GraphDatabase.java:336)
>>>>>  at thesisPrototype.reconnaissanceCore.CFGDBTracer.hook(CFGDBTracer.
>>>>> java:92)
>>>>>  at thesisPrototype.rmiBridge.TracerProxy.hook(TracerProxy.java:16)
>>>>>  at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
>>>>>  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>>>>>  at java.lang.reflect.Method.invoke(Unknown Source)
>>>>>  at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
>>>>>  at sun.rmi.transport.Transport$1.run(Unknown Source)
>>>>>  at sun.rmi.transport.Transport$1.run(Unknown Source)
>>>>>  at java.security.AccessController.doPrivileged(Native Method)
>>>>>  at sun.rmi.transport.Transport.serviceCall(Unknown Source)
>>>>>  at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
>>>>>  at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown 
>>>>> Source)
>>>>>  at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown 
>>>>> Source)
>>>>>  at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
>>>>>  at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>>>>>  at java.lang.Thread.run(Unknown Source)
>>>>>
>>>>> Please, .. I need to fix that issue as soon as possible and I would be 
>>>>> more than grateful for any help...
>>>>>
>>>>>
>>>>> On Saturday, November 22, 2014 5:39:15 PM UTC+1, Markus Gutmann wrote:
>>>>>>
>>>>>> _gdbFactory = new GraphDatabaseFactory();
>>>>>> _gdbService = _gdbFactory.newEmbeddedDatabase(_gdbPath);
>>>>>> _gdbEngine = new ExecutionEngine(_gdbService);
>>>>>> do some work
>>>>>> disconnect from the gdbdo some workdisconnect from the gdb
>>>>>>
>>>>>> I am using a local Neo4j server instance and the Neo4j Java API to 
>>>>>> access a graph-database (gdb).
>>>>>>
>>>>>> I simply want to achieve the following workflow:
>>>>>>
>>>>>>    1. connect to the local gdb from a Java program
>>>>>>    
>>>>>>    I do this using:
>>>>>>    
>>>>>>    _gdbFactory = new GraphDatabaseFactory();
>>>>>>    _gdbService = _gdbFactory.newEmbeddedDatabase(_gdbPath);
>>>>>>    _gdbEngine = new ExecutionEngine(_gdbService);
>>>>>>    
>>>>>>    2. then disconnect using.
>>>>>>    
>>>>>>    _gdbService.shutdown();
>>>>>>    
>>>>>>    3. connect with another process to the same gdb
>>>>>>    
>>>>>>    e.g. with the locally installed Neo4j program.
>>>>>>    
>>>>>>    4. disconnect from the gdb from this process
>>>>>>    
>>>>>>    e.g. by simply clicking the "stop" button at the Neo4j program.
>>>>>>    
>>>>>>    5. again connect to the gdb with the Java program using again the 
>>>>>>    same code as in 1.
>>>>>>    
>>>>>> *Right now, point 5 is not working!*
>>>>>>
>>>>>> The use of
>>>>>>
>>>>>> GraphDatabaseService.shutdown().shutdown
>>>>>>
>>>>>> seems to finalize the gdb in some way that I cannot connect to it any 
>>>>>> more.
>>>>>>
>>>>>> After reconnecting I get an Exception which tells me: *"This 
>>>>>> database is shutdown!"*
>>>>>>
>>>>>> So, my question is:
>>>>>>
>>>>>> What is the common way to connect - disconnect - reconnect to a Neo4J 
>>>>>> gdb ? Is there an alternative to the shutdown-method from above?
>>>>>>
>>>>>  -- 
>>>>> 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 [email protected].
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>  -- 
>>> 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 [email protected] <javascript:>.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to