4 Replies Latest reply on Jun 10, 2015 3:40 AM by Sławomir Ossowski

    Jboss7 + neo4j + hibernate-ogm = StoreLockException?

    Sławomir Ossowski Newbie

      I'm trying to setup neo4j under JBoss7 using hibernate=ogm, heres my pon.xml:

      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>Think01</groupId>
        <artifactId>CityMiners</artifactId>
        <packaging>war</packaging>
        <version>1.0</version>
        <name>RESTfulDemoApplication Maven Webapp</name>
        <url>http://maven.apache.org</url>
        <repositories>
        <repository>
        <id>jboss</id>
        <url>http://repository.jboss.org/maven2</url>
        </repository>
        </repositories>

        <dependencies>
        <dependency>
        <groupId>org.jboss.ejb3</groupId>
        <artifactId>jboss-ejb3-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
        </dependency>


        <dependency>
        <groupId>org.hibernate.ogm</groupId>
        <artifactId>hibernate-ogm-neo4j</artifactId>
        <version>4.1.3.Final</version>
        </dependency>
        </dependencies>
        <build>
        <finalName>CityMiners</finalName>
        </build>
      </project>

      here's my persistance.xml:

      <?xml version="1.0" encoding="UTF-8" ?>
      <persistence xmlns="http://java.sun.com/xml/ns/persistence"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
        <persistence-unit name="ogm-neo4j" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
        <properties>
        <property name="hibernate.ogm.neo4j.database_path" value="d:/dev/q7"/>
        <property name="hibernate.ogm.datastore.provider" value="neo4j_embedded"/>
        <property name="hibernate.search.default.directory_provider" value="ram" />
        </properties>
        </persistence-unit>
      </persistence>

      here's my singleton bean:

      @Singleton
      @Startup
      public class Test {
        private EntityManagerFactory emf;

        @PostConstruct
        public void init() {
        emf = Persistence.createEntityManagerFactory("ogm-neo4j");
        }

        @PreDestroy
        public void kill() {
        emf.close();
        }
      }

      and heres what I receive after deploy:

      [2015-06-06 11:04:14,734] Artifact CityMiners:war: java.lang.Exception: {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"CityMiners.war\".component.Test.START" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"CityMiners.war\".component.Test.START: java.lang.IllegalStateException: JBAS011048: Failed to construct component instance
        Caused by: java.lang.IllegalStateException: JBAS011048: Failed to construct component instance
        Caused by: javax.ejb.EJBException: javax.persistence.PersistenceException: Unable to build entity manager factory
        Caused by: javax.persistence.PersistenceException: Unable to build entity manager factory
        Caused by: org.hibernate.service.spi.ServiceException: OGM000071: Unable to start datatore provider
        Caused by: java.lang.RuntimeException: Error starting org.neo4j.kernel.EmbeddedGraphDatabase, d:\\dev\\q7
        Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.StoreLockerLifecycleAdapter@c5c0fa' was successfully initialized, but failed to start. Please see attached cause exception.
        Caused by: org.neo4j.kernel.StoreLockException: Unable to obtain lock on store lock file: d:\\dev\\q7\\store_lock. Please ensure no other process is using this database, and that the directory is writable (required even for read-only access)
        Caused by: java.io.IOException: Couldn't lock lock file d:\\dev\\q7\\lock because another process already holds the lock."}}

      the stack trace says "Couldn't lock lock file d:\dev\q7\lock because another process already holds the lock." but I'm pretty sure no external process even touches that file ( I do not run another neo4j proces in parallel ) - it looks like somehow JBoss itself holds that lock...

      do you know how to come over this?
      Thanks in advance!