It can be that the graph database and index service are shut down
twice. The first time when you call snaService.shutDown() in the
finally-block and the next time when the JVM exits, due to the
registering of a shutdown hook (which I assume shuts down the graph
database and index service). So try to only shut down the services
once, it'd probably be fine to just skip registering that shutdown
hook.

Another thing, I feel that you look at an EmbeddedGraphDatabase
instance kind of like an SQL connection... something that should be
closed as soon as possible, am I right? This is very much NOT the case
with Neo4j... you are encouraged to keep a graph database instance
alive as long as possible. A better way to solve your model would be
to have a graph database instance started once and sitting and waiting
for incoming requests as long as your service should be available.

2010/6/17 Arijit Mukherjee <ariji...@gmail.com>:
> Hi
>
> I'm facing a problem with Neo4j (I'm using the 1.0 apoc version available at
> the website) while shutting down the graph DB service and the index service.
>
> I've a class called SNAService which stores the GraphDatabaseService (and
> EmbeddedGraphDatabase) and the IndexService (a LuceneIndexService. This
> class initializes these components at the start:
>
> public void setUpService(final String path) {
>        graphDbService = new EmbeddedGraphDatabase(path);
>        registerShutdownHook(graphDbService);
>        indexService = new LuceneIndexService(graphDbService);
>        ...
> }
>
> There's also a shutDown method as follows:
>
> public void shutDown() {
>        System.out.println("Shutting down Neo4J graph Db service...");
>        indexService.shutdown();
>        graphDbService.shutdown();
> }
>
> The main routine in my application opens the transactions, performs some
> operations on the graph like adding nodes, creating relations (via other
> classes). And then I shutdown the instances after the transactions are
> complete:
>
> try {
>            loadData();
>            Node personToStartFrom = findPerson("TM70052");
>            if (personToStartFrom == null) {
>                System.out.println("ERROR: Subscriber with the given MSISDN
> not found, "
>                        + "the TMN social network doesn't seem to be created
> properly");
>                return;
>            }
>            // Query it for information
>            printFriends(personToStartFrom);
>            //fullTraversal();
>            // Let Neo4j know that the transaction was successful
>            tx.success();
>        } finally {
>            // Finish the transaction and shutdown Neo4j
>            tx.finish();
>            snaService.shutDown();
>        }
>
> But when the shutDown method is invoked, I get this exception:
>
> java.io.IOException: Logical log[neodb/lucene/lucene.log.1] not found
> Unable to close logical log
>        at
> org.neo4j.kernel.impl.transaction.xaframework.XaLogicalLog.deleteCurrentLogFile(XaLogicalLog.java:641)
>        at
> org.neo4j.kernel.impl.transaction.xaframework.XaLogicalLog.close(XaLogicalLog.java:693)
>        at
> org.neo4j.kernel.impl.transaction.xaframework.XaContainer.close(XaContainer.java:102)
>        at
> org.neo4j.index.lucene.LuceneDataSource.close(LuceneDataSource.java:186)
>        at
> org.neo4j.kernel.impl.transaction.XaDataSourceManager.unregisterDataSource(XaDataSourceManager.java:127)
>        at
> org.neo4j.index.lucene.LuceneIndexService.shutdown(LuceneIndexService.java:422)
>        at
> com.connectiva.prototype.sna.domain.SNAServiceImpl.shutDown(SNAServiceImpl.java:63)
>        at com.connectiva.prototype.sna.exec.TestSNA.main(TestSNA.java:116)
> java.io.IOException: Logical log[neodb/nioneo_logical.log.1] not found
>        at
> org.neo4j.kernel.impl.transaction.xaframework.XaLogicalLog.deleteCurrentLogFile(XaLogicalLog.java:641)
>        at
> org.neo4j.kernel.impl.transaction.xaframework.XaLogicalLog.close(XaLogicalLog.java:693)
>        at
> org.neo4j.kernel.impl.transaction.xaframework.XaContainer.close(XaContainer.java:102)
>        at
> org.neo4j.kernel.impl.nioneo.xa.NeoStoreXaDataSource.close(NeoStoreXaDataSource.java:237)
>        at
> org.neo4j.kernel.impl.nioneo.xa.NioNeoDbPersistenceSource.stop(NioNeoDbPersistenceSource.java:77)
>        at
> org.neo4j.kernel.GraphDbInstance.shutdown(GraphDbInstance.java:236)
>        at
> org.neo4j.kernel.EmbeddedGraphDbImpl.shutdown(EmbeddedGraphDbImpl.java:175)
>        at
> org.neo4j.kernel.EmbeddedGraphDatabase.shutdown(EmbeddedGraphDatabase.java:115)
>        at
> com.connectiva.prototype.sna.domain.SNAServiceImpl.shutDown(SNAServiceImpl.java:64)
>        at com.connectiva.prototype.sna.exec.TestSNA.main(TestSNA.java:116)
>
> If I comment out the shutDown invocation, the exception is not thrown, but
> the program never stops. Being a newbie, I don't fully understand what's
> going on here. Can anyone please help me?
>
> Regards
>
> Arijit
>
> --
> "And when the night is cloudy,
> There is still a light that shines on me,
> Shine on until tomorrow, let it be."
> _______________________________________________
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Mattias Persson, [matt...@neotechnology.com]
Hacker, Neo Technology
www.neotechnology.com
_______________________________________________
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to