Results 1 to 9 of 9

Thread: Trying to get a simple example to work

  1. #1
    Join Date
    Jul 2011
    Location
    Denmark
    Posts
    31

    Question Trying to get a simple example to work

    Hello

    I'm trying to get spring-data-neo4j to work, but aspectj doesnt work it seems.

    Did this:
    - Made fresh empty simple maven project.
    - Converted to AspectJ project.
    - Added this POM (as described in documentation):
    Code:
    <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>org.test</groupId>
      <artifactId>simple-maven-spring-data-neo4j-test</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <name>Test1</name>
      <description>Trying to get SDN to work in a simple Maven project</description>
      
      <repositories>
      	<repository>
        	<id>spring-maven-milestone</id>
        	<name>Springframework Maven Repository</name>
        	<url>http://maven.springframework.org/milestone</url>
    	</repository>
      </repositories>
      
      <dependencies>
    	<dependency>
    	    <groupId>org.springframework.data</groupId>
    	    <artifactId>spring-data-neo4j</artifactId>
    	    <version>2.0.0.RC1</version>
    	</dependency>
    	
    	<dependency>
    	    <groupId>org.aspectj</groupId>
    	    <artifactId>aspectjrt</artifactId>
    	    <version>1.6.12</version>
    	</dependency>
      </dependencies>
      <build>
      	<plugins>
      		<plugin>
    		    <groupId>org.codehaus.mojo</groupId>
    		    <artifactId>aspectj-maven-plugin</artifactId>
    		    <version>1.2</version>
    		    <dependencies>
    		        <!-- NB: You must use Maven 2.0.9 or above or these are ignored (see MNG-2972) -->
    		        <dependency>
    		            <groupId>org.aspectj</groupId>
    		            <artifactId>aspectjrt</artifactId>
    		            <version>1.6.12</version>
    		        </dependency>
    		        <dependency>
    		            <groupId>org.aspectj</groupId>
    		            <artifactId>aspectjtools</artifactId>
    		            <version>1.6.12</version>
    		        </dependency>
    		    </dependencies>
    		    <executions>
    		        <execution>
    		            <goals>
    		                <goal>compile</goal>
    		                <goal>test-compile</goal>
    		            </goals>
    		        </execution>
    		    </executions>
    		    <configuration>
    		        <outxml>true</outxml>
    		        <aspectLibraries>
    		            <aspectLibrary>
    		                <groupId>org.springframework</groupId>
    		                <artifactId>spring-aspects</artifactId>
    		            </aspectLibrary>
    		            <aspectLibrary>
    		                <groupId>org.springframework.data</groupId>
    		                <artifactId>spring-data-neo4j</artifactId>
    		            </aspectLibrary>
    		        </aspectLibraries>
    		        <source>1.6</source>
    		        <target>1.6</target>
    		    </configuration>
    		</plugin>
      	</plugins>
      </build>
    </project>
    Now there is an error in the documentation (http://static.springsource.org/sprin.../html/#d0e2885). In the plugin section there is a reference to spring-datastore-neo4j. There is no such thing - its "spring-data-neo4j". Also, why use 1.2 of the aspectj-maven-plugin when there is a 1.4?

    - I then made a simple entity:
    Code:
    package org.test.simplemaven;
    
    import org.springframework.data.neo4j.annotation.NodeEntity;
    
    @NodeEntity
    public class TestEntity {
    	private String blah;
    }
    - and something to run it:
    Code:
    package org.test.simplemaven;
    
    public class App {
    	public static void main(String args) {
    		TestEntity te = new TestEntity();
    		te.persist();
    	}
    }
    Now both STS and a "mvn clean compile" complains that there is no such thing as persist().
    Here is the error:
    Code:
    [INFO] 1error
    [INFO] -------------------------------------------------------------
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 2.539s
    [INFO] Finished at: Tue Nov 15 21:37:05 CET 2011
    [INFO] Final Memory: 10M/81M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.1:compile (default-compile) on project simple-maven-spring-data-neo4j-test: Compilation failure
    [ERROR] /workspace/simple-maven-spring-data-neo4j-test/src/main/java/org/test/simplemaven/App.java:[6,4] cannot find symbol
    [ERROR] symbol  : method persist()
    [ERROR] location: class org.test.simplemaven.TestEntity
    Whats up?
    Last edited by Gr3y; Nov 17th, 2011 at 01:31 PM.

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

    Default

    You've added a dependency to spring-data-neo4j which since 2.0 contains the core + non-aspectj mapping mode.

    If you want to have the aspectj-mapping mode you have to depend on spring-data-neo4j-aspects. (this is also wrong in this part of the docs)

    We had some nasty bugs with the newer AJ maven plugins, that's why it is still 1.2

    Thanks for pointing out the documentation issue.

    Cheers

    Michael

  3. #3
    Join Date
    Jul 2011
    Location
    Denmark
    Posts
    31

    Default

    Hello again Michael
    Thanks for helping.

    So I've added the following to pom.xml:
    Code:
    <dependency>
    	<groupId>org.springframework.data</groupId>
    	<artifactId>spring-data-neo4j-aspects</artifactId>
    	<version>2.0.0.RC1</version>
    </dependency>
    Everything else remains the same.

    Unfortunately it didn't help.

    I checked the pom dependency hirarchy, and spring-data-neo4j-aspects is being referenced ok.

    My "TestEntity" class however, has no injected aspects.
    And persist() still doesn't work.

    Does it work in your end if you follow my example steps?

    I'll try in STS 2.7.x tomorrow.

  4. #4
    Join Date
    Jul 2011
    Location
    Denmark
    Posts
    31

    Default

    Tried some further tests with spring-data-neo4j (sdn) and spring-data-neo4j-aspects (snda)

    One seems to exclude the other. If I force spring-data-neo4j-aspects (sdna) to be on the buildpath, then sdn gets removed, and then stuff annotated with @NoteEntity breaks, because the NodeEntity class is no longer available.

    spring-aspects and sdn is in the buildpath by default (even with sdn removed from the pom)

    Also tested with STS 2.7.2: Didn't work either.

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

    Default

    spring-data-neo4j-aspects has a transitive dependency to spring-data-neo4j, so it should be pulled in automatically.

    I'll look into it.

    Cheers

    Michael

  6. #6
    Join Date
    Jul 2011
    Location
    Denmark
    Posts
    31

    Default

    Yeah I realize that. I noticed from the dependecy hirarchy.
    It was only a test to try to force sdn and sdna to coexist.

  7. #7
    Join Date
    Oct 2011
    Posts
    9

    Default

    I had a very similar problem (only a few threads away).

    By changing
    Code:
      
       <aspectLibrary>
            <groupId>org.springframework.data</groupId>
    	<artifactId>spring-data-neo4j</artifactId>
       </aspectLibrary>
    to

    Code:
      
       <aspectLibrary>
            <groupId>org.springframework.data</groupId>
    	<artifactId>spring-data-neo4j-aspects</artifactId>
       </aspectLibrary>
    it fixed my (similar sounding) problem.

  8. #8
    Join Date
    Jul 2011
    Location
    Denmark
    Posts
    31

    Default

    Hey c-fly.

    EDIT:
    Deleted old reply. Didn't notice that you were talking about <aspectLibrary>.

    Your fix worked. Thank you both for your time!

    Awesome, can finally get going.
    Last edited by Gr3y; Nov 17th, 2011 at 11:38 AM.

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

    Default

    Sorry, I assumed you changed it in both places.

    I updated the docs to reflect that. Thanks again for pointing it out.

    Cheers

    Michael

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
  •