Spring Data Graph for Neo4j in Grails

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Spring Data Graph for Neo4j in Grails

mordekai
Hello,

I am trying to get the Spring Data Graph for Neo4J to work in our Grails application, but I am having some trouble.

I was wondering if anyone else is trying to get this to work also and has made more progress than me.

Spring Data Graph makes use of the AspectJ weaver to add methods to the domain classes, but I do not know how to enable aspectj in grails. The examples all use Maven...

I have also tried using the <context:load-time-weaver />, but I did not get very far.
I keep getting the exception: java.lang.IllegalStateException: No LoadTimeWeaver available

This is what I have so far:

in conf/spring/resources.xml

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:datagraph="http://www.springframework.org/schema/data/graph"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
                http://www.springframework.org/schema/data/graph http://www.springframework.org/schema/data/graph/datagraph-1.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

    <context:spring-configured/>
    <context:annotation-config/>
    <context:load-time-weaver />
       
    <datagraph:config storeDirectory="data/neo4j-db"/>
    <datagraph:repositories base-package="com.cg.domain" graph-database-context-ref="graphDatabaseContext"/>
       
    <tx:annotation-driven mode="aspectj" transaction-manager="transactionManager"/>
   
    <alias name="neo4jTransactionManager" alias="transactionManager"/>
 
        <bean id="neo4jTransactionManagerService"
                        class="org.neo4j.kernel.impl.transaction.SpringTransactionManager">
            <constructor-arg ref="graphDatabaseService"/>
        </bean>
        <bean id="neo4jUserTransactionService"
                        class="org.neo4j.kernel.impl.transaction.UserTransactionImpl">
            <constructor-arg ref="graphDatabaseService"/>
        </bean>
         
        <bean id="neo4jTransactionManager"
                        class="org.springframework.transaction.jta.JtaTransactionManager">
            <property name="transactionManager" ref="neo4jTransactionManagerService"/>
            <property name="userTransaction" ref="neo4jUserTransactionService"/>
        </bean>
</beans>


In web-app/META-INF/aop.xml

<aspectj>
    <weaver options="-showWeaveInfo" />
    <aspects>
                <aspect name="org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect"/>
                <aspect name="org.springframework.scheduling.aspectj.AnnotationAsyncExecutionAspect"/>
                <aspect name="org.springframework.transaction.aspectj.AnnotationTransactionAspect"/>
        <aspect name="org.springframework.data.graph.neo4j.support.node.Neo4jNodeBacking"/>
                <aspect name="org.springframework.data.graph.neo4j.support.relationship.Neo4jRelationshipBacking"/>
    </aspects>
</aspectj>


And I added this to my JAVA_OPTS:
-javaagent:spring-agent.jar

Without the weaving I obviously get error messages like:
No signature of method: com.xx.domain.User.persist() is applicable for argument types: () values: []

Any help would be much appreciated!

Maarten
Reply | Threaded
Open this post in threaded view
|

Re: Spring Data Graph for Neo4j in Grails

johnlondon
Hi Mordekai,

I know this was posted a long time ago, but I was wondering whether you ever managed to get Grails to work with spring-data-neo4j please?

Many thanks,

John