Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: spring-data-neo4j: Unable to lock store

  1. #1
    Join Date
    Nov 2011
    Posts
    19

    Default spring-data-neo4j: Unable to lock store

    Hello,
    i have a problem integrating spring-data and neo4j i did'nt have before:
    every startup of the system i get this error i don't know where does it comes from, does anybody have any idea?

    "java.lang.IllegalStateException: Unable to lock store [....\heroku\stark-spring-4279\target\db\graph\neostore], this is usually a result of some other Neo4j kernel running using the same store."

    I don't have any other process using this store and what i do i only startup the application.
    i attach my relevant informations:

    from pom.xml
    <properties>
    <org.springframework.version>3.1.1.RELEASE</org.springframework.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
    <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.0.1</version>
    <scope>provided</scope>
    </dependency>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>${org.springframework.version}</version>
    <exclusions>
    <exclusion>
    <artifactId>commons-logging</artifactId>
    <groupId>commons-logging</groupId>
    </exclusion>
    </exclusions>
    </dependency>



    <dependency>
    <groupId>com.github.jsimone</groupId>
    <artifactId>webapp-runner</artifactId>
    <version>7.0.22.3</version>
    <scope>provided</scope>
    </dependency>

    <dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-neo4j-rest</artifactId>
    <version>2.0.1.RELEASE</version>
    </dependency>
    <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-web</artifactId>
    <version>3.0.6.RELEASE</version>
    </dependency>
    <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-config</artifactId>
    <version>3.0.6.RELEASE</version>
    </dependency>
    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>4.2.0.Final</version>
    </dependency>
    <dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.1</version>
    <type>jar</type>
    </dependency>
    </dependencies>


    my AppllicationContext

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schem...ring-beans.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schem...ng-context.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
    http://www.springframework.org/schema/mvc http://www.springframework.org/schem...spring-mvc.xsd
    http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd">

    <context:annotation-config/>
    <context:spring-configured />
    <context:component-scan base-package="com.example.controller"/>
    <!-- <context:component-scan base-package="com.example.controller">
    <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Control ler" />
    </context:component-scan>-->

    <mvc:annotation-driven/>
    <mvc:resources mapping="/images/**" location="/images/"/>
    <mvc:resources mapping="/resources/**" location="/resources/"/>
    <mvc:resources mapping="/favicon.ico" location="/images/favicon.ico"/>

    <tx:annotation-driven/>
    <neo4j:repositories base-package="com.example.service" />

    <bean id="jspViewResolver" class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlVi ew" />
    <property name="prefix" value="/WEB-INF/views/" />
    <property name="suffix" value=".jsp" />
    </bean>

    <!-- <bean id="findtoothUserDetailsService" class="com.example.service.UserRepositoryImpl"/>-->

    <beans profile="default">
    <neo4j:config storeDirectory="target/db/graph"/>
    </beans>
    <beans profile="prod">
    <bean class="org.springframework.data.neo4j.rest.SpringR estGraphDatabase" id="graphDatabaseService">
    <constructor-arg index="0" value="#{systemEnvironment['NEO4J_REST_URL']}"/>
    <constructor-arg index="1" value="#{systemEnvironment['NEO4J_LOGIN']}"/>
    <constructor-arg index="2" value="#{systemEnvironment['NEO4J_PASSWORD']}"/>
    </bean>
    <neo4j:config graphDatabaseService="graphDatabaseService"/>
    </beans>


    </beans>

    my security.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <beans:beans xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schem...ring-beans.xsd
    http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">

    <global-method-security pre-post-annotations="enabled">
    <!-- AspectJ pointcut expression that locates our "post" method and applies security that way
    <protect-pointcut expression="execution(* bigbank.*Service.post*(..))" access="ROLE_TELLER"/>
    -->
    </global-method-security>

    <http pattern="/resources/**" security="none" />
    <http pattern="/images/**" security="none" />
    <http pattern="/css/**" security="none" />
    <http pattern="/login" security="none" />

    <http auto-config="true" use-expressions="false">
    <intercept-url pattern="/**" access="ROLE_USER" />
    <intercept-url pattern="/user/*" access="ROLE_USER"/>
    <intercept-url pattern="/populate/**" access="ROLE_ADMIN" />
    <intercept-url pattern="/auth/login" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
    <intercept-url pattern="/auth/register" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
    <intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
    <form-login login-page="/login" default-target-url="/user" authentication-failure-url="/auth/login?login_error=true"/>
    </http>

    <authentication-manager>
    <!-- <authentication-provider user-service-ref="findtoothUserDetailsService">
    <password-encoder hash="md5">
    <salt-source system-wide="cewuiqwzie"/>
    </password-encoder>
    </authentication-provider>-->
    <authentication-provider>
    <password-encoder hash="md5"/>
    <user-service>
    <user name="rod" password="pwd" authorities="ROLE_ADMIN, ROLE_USER, ROLE_TELLER" />
    <user name="dianne" password="65d15fe9156f9c4bbffd98085992a44e" authorities="ROLE_USER,ROLE_TELLER" />
    <user name="scott" password="pwd" authorities="ROLE_USER" />
    <user name="peter" password="pwd" authorities="ROLE_USER" />
    </user-service>
    </authentication-provider>
    </authentication-manager>
    </beans:beans>


    this is the entire stack trace
    INFO: Initializing Spring FrameworkServlet 'spring'
    org.neo4j.graphdb.TransactionFailureException: Could not create data source [nioneodb], see nested exception for cause of error
    at org.neo4j.kernel.impl.transaction.TxModule.registe rDataSource(TxModule.java:161)
    at org.neo4j.kernel.GraphDbInstance.start(GraphDbInst ance.java:104)
    at org.neo4j.kernel.EmbeddedGraphDbImpl.<init>(Embedd edGraphDbImpl.java:190)
    at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(Embe ddedGraphDatabase.java:77)
    at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(Embe ddedGraphDatabase.java:61)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:147)
    at ....
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.IllegalStateException: Unable to lock store [....\houla\heroku\stark-spring-4279\target\db\graph\neostore], this is usually a result of some oth
    er Neo4j kernel running using the same store.
    ...
    16-mag-2012 14.45.17 org.apache.catalina.core.ApplicationContext log
    GRAVE: StandardWrapper.Throwable
    .......

    thank you for any help

  2. #2
    Join Date
    Jan 2011
    Location
    Dresden, Germany
    Posts
    525

    Default

    Can it be that the spring context is refreshed twice w/o shutting down the previous one correctly?

    Is it on your local host? You might set a breakpoint in the EmbeddedGraphDb constructor and see from which places it is called twice?

    Perhaps this discussion also helps you.

  3. #3
    Join Date
    Aug 2010
    Posts
    26

    Default

    Looks like the problem is here at first glance

    <beans profile="default">
    <neo4j:config storeDirectory="target/db/graph"/>
    </beans>
    <beans profile="prod">
    <bean class="org.springframework.data.neo4j.rest.SpringR estGraphDatabase" id="graphDatabaseService">
    <constructor-arg index="0" value="#{systemEnvironment['NEO4J_REST_URL']}"/>
    <constructor-arg index="1" value="#{systemEnvironment['NEO4J_LOGIN']}"/>
    <constructor-arg index="2" value="#{systemEnvironment['NEO4J_PASSWORD']}"/>
    </bean>
    <neo4j:config graphDatabaseService="graphDatabaseService"/>
    </beans>

  4. #4
    Join Date
    Jan 2011
    Location
    Dresden, Germany
    Posts
    525

    Default

    perhaps a problem with selecting the profile?

    Michael

  5. #5
    Join Date
    Nov 2011
    Posts
    19

    Default

    Seems to me something related to security, when i try to add security framework to heroku sample project https://github.com/jamesward/hello-java-spring-neo4j i get this error.

    this my applicatinoContext
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
    xmlns:security="http://www.springframework.org/schema/security"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-3.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schem...ontext-3.0.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schem...ing-tx-3.0.xsd
    http://www.springframework.org/schema/mvc http://www.springframework.org/schem...ng-mvc-3.0.xsd
    http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schem...-neo4j-2.0.xsd
    http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">

    <context:annotation-config />
    <context:component-scan base-package="com.example" />
    <context:spring-configured />
    <neo4j:repositories base-package="com.example.service" />

    <mvc:annotation-driven/>
    <tx:annotation-driven />

    <bean id="jspViewResolver" class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlVi ew" />
    <property name="prefix" value="/WEB-INF/jsp/" />
    <property name="suffix" value=".jsp" />
    </bean>


    <neo4j:config storeDirectory="target/neo4j-db"/>

    </beans>

    and this is the security.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans:beans xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-3.0.xsd
    http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">

    <global-method-security pre-post-annotations="enabled">
    <!-- AspectJ pointcut expression that locates our "post" method and applies security that way
    <protect-pointcut expression="execution(* bigbank.*Service.post*(..))" access="ROLE_TELLER"/>
    -->
    </global-method-security>

    <http use-expressions="true">
    <intercept-url pattern="/secure/extreme/**" access="hasRole('ROLE_SUPERVISOR')"/>
    <intercept-url pattern="/secure/**" access="isAuthenticated()"/>
    <!-- Disable web URI authorization, as we're using <global-method-security> and have @Secured the services layer instead
    <intercept-url pattern="/listAccounts.html" access="isRememberMe()" />
    <intercept-url pattern="/post.html" access="hasRole('ROLE_TELLER')" />
    -->
    <intercept-url pattern="/**" access="permitAll"/>
    <form-login/>
    <logout/>
    <remember-me/>
    <!--
    Uncomment to enable X509 client authentication support
    <x509 />
    -->
    <!-- Uncomment to limit the number of sessions a user can have -->
    <session-management invalid-session-url="/timeout.jsp">
    <concurrency-control max-sessions="1" error-if-maximum-exceeded="true"/>
    </session-management>

    </http>

    <authentication-manager>
    <authentication-provider>
    <user-service>
    <user name="jimi" password="jimi" authorities="ROLE_USER, ROLE_ADMIN"/>
    <user name="bob" password="bob" authorities="ROLE_USER"/>
    </user-service>
    </authentication-provider>
    </authentication-manager>

    </beans:beans>

    using security 3.0.6

    any hint?

    thanks both

  6. #6
    Join Date
    Nov 2011
    Posts
    19

    Default

    I realized is something happening only locally, if i change

    <neo4j:config storeDirectory="target/neo4j-db"/>
    to
    <bean class="org.springframework.data.neo4j.rest.SpringR estGraphDatabase" id="graphDatabaseService">
    <constructor-arg index="0" value="#{systemEnvironment['NEO4J_REST_URL']}"/>
    <constructor-arg index="1" value="#{systemEnvironment['NEO4J_LOGIN']}"/>
    <constructor-arg index="2" value="#{systemEnvironment['NEO4J_PASSWORD']}"/>
    </bean>
    <neo4j:config graphDatabaseService="graphDatabaseService"/>

    then seems to work...

    any idea?

    thank you

  7. #7
    Join Date
    Aug 2010
    Posts
    26

    Default

    You have two neo4j:config elements and mixing up configuring locally and restfully I think.

    Your setup looks to be similar to mine. See if this helps.

    Code:
           <neo4j:config graphDatabaseService="graphDatabaseService"/>
    
    	<bean id="graphDatabaseService" 
    		class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase">
    	  <constructor-arg index="0" value="http://localhost:7474/db/data" />
    	</bean>
    	
    	<bean id="executionEngine" class="org.neo4j.cypher.javacompat.ExecutionEngine">
      		<constructor-arg index="0" ref="graphDatabaseService" />
    	</bean>

  8. #8
    Join Date
    Nov 2011
    Posts
    19

    Default

    i'm using embedded db when running locally and rest when i run on heroku, which i think have no problem.
    When i run locally (embedded) with security config the problem comes out don't know why; using rest always works both localhost and remote host.
    i would like to use embedded to compare performance of both situations.

    thanks

  9. #9
    Join Date
    Aug 2010
    Posts
    26

    Default

    Interesting, I could probably benefit from being able to run both at once myself. I currently do a batch import in embedded mode then run a different config to switch to rest.

    You might need to configure at least one of the two methods manually.

    Are you trying to connect to the same store with both methods?

  10. #10
    Join Date
    Nov 2011
    Posts
    19

    Default

    i don't think u can run both at once, i think u can run or embedded or rest but not at the same time.
    to configure use maven or spring profiles, it will switch at build time

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •