Announcement Announcement Module
Collapse
No announcement yet.
Cross Store aspectj errors in build. Not sure why Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cross Store aspectj errors in build. Not sure why

    Here are some examples of what I see when I run maven.

    [ERROR] can't override org.springframework.data.neo4j.aspects.core.NodeBa cked org.springframework.data.neo4j.aspects.core.NodeBa cked.persist() with T org.springframework.data.neo4j.aspects.core.NodeBa cked.persist() return types don't match
    [ERROR] can't override org.springframework.data.neo4j.aspects.core.NodeBa cked org.springframework.data.neo4j.aspects.core.NodeBa cked.persist() with T org.springframework.data.neo4j.aspects.core.NodeBa cked.persist() return types don't match
    [ERROR] can't override java.lang.Object org.springframework.data.neo4j.mapping.ManagedEnti ty.persist() with T org.springframework.data.neo4j.aspects.core.NodeBa cked.persist() return types don't match
    [ERROR] can't override java.lang.Object org.springframework.data.neo4j.mapping.ManagedEnti ty.persist() with T org.springframework.data.neo4j.aspects.core.NodeBa cked.persist() return types don't match
    [ERROR] can't override java.lang.Object org.springframework.data.neo4j.aspects.core.GraphB acked.getPersistentState() with org.neo4j.graphdb.Node org.springframework.data.neo4j.aspects.core.NodeBa cked.getPersistentState() return types don't match
    [ERROR] can't override java.lang.Object org.springframework.data.neo4j.aspects.core.GraphB acked.getPersistentState() with org.neo4j.graphdb.Node org.springframework.data.neo4j.aspects.core.NodeBa cked.getPersistentState() return types don't match


    Thanks

    Mark

  • #2
    What AJ version are you using, and what SDN version? Do you have an example for your entity and the pom.xml.

    Sounds like a generics issue. So perhaps something about the Java-version?

    Can you share the relevant parts of your projects and/or a sample project? Then I can also ask Andy Clement the AJ project lead to look into this.

    Comment


    • #3
      Yeah, this project I can't share anything in code.

      But here are the versions

      Java 7
      SDN - <spring-data-neo4j.version>2.1.0.RELEASE</spring-data-neo4j.version>
      AspectJ - <aspectj.version>1.6.12</aspectj.version>

      Also we are using Groovy so in the compiler plugin
      Code:
      <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-compiler-plugin</artifactId>
                      <version>2.3.2</version>
                      <configuration>
                          <source>1.7</source>
                          <target>1.7</target>
                          <compilerId>groovy-eclipse-compiler</compilerId>
                          <verbose>false</verbose>
                          <encoding>UTF-8</encoding>
                      </configuration>
                      <dependencies>
                        <dependency>
                          <groupId>org.codehaus.groovy</groupId>
                          <artifactId>groovy-eclipse-compiler</artifactId>
                          <version>2.7.0-01</version>
                        </dependency>
                      </dependencies>
                  </plugin>
      FOr the aspectJ plugin

      Code:
      <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-aspects</artifactId>
                              </aspectLibrary>
                          </aspectLibraries>
                          <source>1.7</source>
                          <target>1.7</target>
                      </configuration>
                  </plugin>
      I guess I can post one domain object

      Code:
      @Entity
      @Table(name="AccountUser")
      @NodeEntity(partial = true)
      class Account implements UserDetails {
      
        public static final String FAVORITE_TABLES = "FAVORITE_TABLES";
        public static final String FAVORITE_VIDEOS = "FAVORITE_VIDEOS";
        public static final String FRIENDS_LIST = "FRIENDS_LIST";
        public static final String USER_VIDEOS = "USER_VIDEOS";
        public static final String USER_MAILBOX = "USER_MAILBOX";
      
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        Long id
      
        String firstName
        String lastName
        Locale locale
        TimeZone timeZone
        Date lastModified
        Date birthday
        @ManyToOne
        @JoinColumn(name="currency_id")
        Currency currencyId
        String email
      
      
        @ManyToMany(cascade = CascadeType.ALL)
        Set<UserGroup> groups
      
        @ManyToMany(cascade = CascadeType.ALL)
        Set<UserRole> roles
      
          // Properties for UserDetails
        Collection<? extends GrantedAuthority> getAuthorities() {
          Collection<? extends GrantedAuthority> authorities = new ArrayList<? extends GrantedAuthority>()
          roles.each{ role ->
            authorities << new SimpleGrantedAuthority(role.role)
          }
          groups.each{ group ->
            authorities << new SimpleGrantedAuthority(group.group)
          }
          return authorities
        }
      
        String password
        String username
      
        @Transient
        boolean accountNonExpired = true
      
        @Transient
        boolean accountNonLocked = true
      
        @Transient
        boolean credentialsNonExpired = true
      
        @Transient
        boolean enabled = true
      
        // Neo4 Graph stuff
      
        @GraphId
        //@Transient
        Long nodeId
      
        @RelatedTo(type = Account.FAVORITE_TABLES)
        //@Transient
        Set<GameTable> favoriteTables
      
        public void addFavoriteTables(GameTable favoriteTable) {
          if (favoriteTables == null) {
              this.favoriteTables = new HashSet<GameTable>();
          }
          favoriteTables.add(favoriteTable);
        }
      
        @RelatedTo(type = Account.FAVORITE_VIDEOS)
        //@Transient
        Set<Video> favoriteVideos
      
        public void addFavoriteVideos(Video favoriteVideo) {
          if (favoriteVideos == null) {
              this.favoriteVideos = new HashSet<Video>();
          }
          favoriteVideos.add(favoriteVideo);
        }
      
        @RelatedToVia(type = Account.USER_VIDEOS)
        //@Transient
        Set<VideoUpload> myVideos
      
        public void addMyVideo(VideoUpload myVideo) {
          if (myVideos == null) {
              this.myVideos = new HashSet<VideoUpload>();
          }
          myVideos.add(myVideo);
        }
      
        @RelatedToVia(type = Account.FRIENDS_LIST)
        //@Transient
        Set<FriendList> friendLists
      
        public void addFriendList(FriendList friendList) {
          if (friendLists == null) {
              this.friendLists = new HashSet<FriendList>();
          }
          friendLists.add(friendList);
        }
      
        @RelatedToVia(type = Account.USER_MAILBOX)
        //@Transient
        Set<MailboxMessage> mailboxMessages
      
        public void addMailboxMessage(MailboxMessage mailboxMessage) {
          if (mailboxMessages == null) {
              this.mailboxMessages = new HashSet<MailboxMessage>();
          }
          mailboxMessages.add(mailboxMessage);
        }
      }
      Thanks Michael

      Mark

      Comment


      • #4
        Forwarded it to Andy Clement for clarification.

        Comment


        • #5
          OK. Since you mentioned something about versions. I bumped up the aspectj version to 1.7.1. So it changed my errors. to

          Code:
          Information:Compilation completed with 28 errors and 11 warnings in 15 sec
          Information:28 errors
          Information:11 warnings
          Warning:ajc: advice defined in org.springframework.orm.jpa.aspectj.JpaExceptionTranslatorAspect has not been applied [Xlint:adviceDidNotMatch]
          Warning:ajc: advice defined in org.springframework.scheduling.aspectj.AbstractAsyncExecutionAspect has not been applied [Xlint:adviceDidNotMatch]
          Warning:ajc: advice defined in org.springframework.data.neo4j.aspects.support.node.Neo4jNodeBacking has not been applied [Xlint:adviceDidNotMatch]
          Warning:ajc: advice defined in org.springframework.data.neo4j.aspects.support.node.Neo4jNodeBacking has not been applied [Xlint:adviceDidNotMatch]
          Warning:ajc: advice defined in org.springframework.data.neo4j.aspects.support.node.Neo4jNodeBacking has not been applied [Xlint:adviceDidNotMatch]
          Warning:ajc: advice defined in org.springframework.data.neo4j.aspects.support.relationship.Neo4jRelationshipBacking has not been applied [Xlint:adviceDidNotMatch]
          Warning:ajc: advice defined in org.springframework.data.neo4j.aspects.support.relationship.Neo4jRelationshipBacking has not been applied [Xlint:adviceDidNotMatch]
          Warning:ajc: advice defined in org.springframework.data.neo4j.aspects.support.relationship.Neo4jRelationshipBacking has not been applied [Xlint:adviceDidNotMatch]
          Warning:ajc: advice defined in org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl has not been applied [Xlint:adviceDidNotMatch]
          Warning:ajc: advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
          Warning:ajc: advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
          /Users/bytor99999/Documents/blah/blah/blahProjects/blah/blah-core/src/main/java/com/blah/account/configuration/JpaDevBeanConfiguration.java
              Error:Error:line (3)ajc: The import com.blah.annotations cannot be resolved
              Error:Error:line (28)ajc: AccountServerApp cannot be resolved to a type
          /Users/bytor99999/Documents/blah/blah/blahProjects/blah/blah-core/src/main/java/com/blah/account/configuration/JpaProdBeanConfiguration.java
              Error:Error:line (3)ajc: The import com.blah.annotations cannot be resolved
              Error:Error:line (28)ajc: AccountServerApp cannot be resolved to a type
          /Users/bytor99999/Documents/blah/blah/blahProjects/blah/blah-core/src/main/java/com/blah/account/domain/device/MobileDevice.java
              Error:Error:line (3)ajc: The import com.blah.account.domain.user.Account cannot be resolved
          /Users/bytor99999/Documents/blah/blah/blahProjects/blah/blah-core/src/main/java/com/blah/account/repository/UserRepository.java
              Error:Error:line (3)ajc: The import com.blah.account.domain.user.Account cannot be resolved
              Error:Error:line (11)ajc: Account cannot be resolved to a type
              Error:Error:line (13)ajc: Account cannot be resolved to a type
          /Users/bytor99999/Documents/blah/blah/blahProjects/blah/blah-core/src/main/java/com/blah/domain/media/Photo.java
              Error:Error:line (4)ajc: The import com.blah.account.domain.user.Account cannot be resolved
              Error:Error:line (24)ajc: Account cannot be resolved to a type
          /Users/bytor99999/Documents/blah/blah/blahProjects/blah/blah-core/src/main/java/com/blah/domain/media/Video.java
              Error:Error:line (4)ajc: The import com.blah.account.domain.user.Account cannot be resolved
              Error:Error:line (28)ajc: Account cannot be resolved to a type
              Error:Error:line (31)ajc: Account cannot be resolved to a type
          /Users/bytor99999/Documents/blah/blah/blahProjects/blah/blah-core/src/main/java/com/blah/operator/configuration/JpaDevBeanConfiguration.java
              Error:Error:line (3)ajc: The import com.blah.annotations cannot be resolved
              Error:Error:line (28)ajc: AdminServerApp cannot be resolved to a type
          /Users/bytor99999/Documents/blah/blah/blahProjects/blah/blah-core/src/main/java/com/blah/operator/configuration/JpaProdBeanConfiguration.java
              Error:Error:line (3)ajc: The import com.blah.annotations cannot be resolved
              Error:Error:line (28)ajc: AdminServerApp cannot be resolved to a type
          /Users/bytor99999/Documents/blah/blah/blahProjects/blah/blah-core/src/main/java/com/blah/operator/domain/operator/OperatorLoginLog.java
              Error:Error:line (41)ajc: Operator cannot be resolved to a type
              Error:Error:line (63)ajc: Operator cannot be resolved to a type
              Error:Error:line (64)ajc: Operator cannot be resolved to a type
              Error:Error:line (67)ajc: Operator cannot be resolved to a type
              Error:Error:line (68)ajc: Operator cannot be resolved to a type
          /Users/bytor99999/Documents/blah/blah/blahProjects/blah/blah-core/src/main/java/com/blah/operator/domain/operator/OperatorSession.java
              Error:Error:line (17)ajc: Operator cannot be resolved to a type
              Error:Error:line (31)ajc: Operator cannot be resolved to a type
              Error:Error:line (32)ajc: Operator cannot be resolved to a type
          /Users/bytor99999/Documents/blah/blah/blahProjects/blah/blah-core/src/main/java/com/blah/operator/repository/OperatorRepository.java
              Error:Error:line (3)ajc: The import com.blah.operator.domain.operator.Operator cannot be resolved
              Error:Error:line (12)ajc: Operator cannot be resolved to a type
              Error:Error:line (19)ajc: Operator cannot be resolved to a type
          Mark
          Last edited by bytor99999; Jan 17th, 2013, 12:11 PM. Reason: remove real company names

          Comment


          • #6
            Now the thing that kind of surprises me is that Operator is in there, since that won't use ajc because it isn't a cross store bean. It is actually straight Spring Data Jpa using a different configuration. So when it is in a classpath running, there is no SDN beans at all.

            Mark

            Comment


            • #7
              So on those latest ones, I got rid of the "Error:Error:line (68)ajc: Operator cannot be resolved to a type"

              By converting the Operator class from Groovy to Java. That is a major bummer and failure on ajc to not be able to use Groovy domain classes.

              Mark

              Comment


              • #8
                OK, I have a solution, but it isn't a good solution. I am not sure if it is AspectJ's fault or SDN. But I had to convert every single domain class I had from being a Groovy class to Java classes. Took me a couple of hours, but I don't get those type errors anymore. I am getting an error in running the test, but a normal error

                java.lang.IllegalStateException: Flushing detached entity without a persistent state, this had to be created first.

                Which means I created a new domain object and didn't attach it to the entityManager. But only went through the repository. Will post that in another thread.

                Should we add a jira ticket on the Groovy issue?

                Thanks

                Mark

                Comment


                • #9
                  Hi,

                  Michael asked me to chime in on this issue. I can't speak to your most recent question but I'll comment on the need to translate from groovy>java. I don't quite speak fluent maven, so can I confirm what you are doing: compiling the groovy/java sources and then doing an AspectJ weaving step. Is that right? This should be fine as long as the groovy compiler is producing suitable output classes for your domain objects and they follow what the Spring Data aspects are looking for. It won't work any other way around because AspectJ won't understand groovy source code. When other source languages are involved, AspectJ should be used just as a bytecode weaver and operates on the compiled output of whatever compiler was used (scala, groovy, javac).

                  cheers,
                  Andy

                  Comment


                  • #10
                    Yes, basically, unless I could figure out how to tell Maven and my IDE for that matter to compile with javac and only instrument the bytecode with ajc. Unfortunately, as it stands it is compiling and instrumenting using ajc as the compiler, which wouldn't understand the Groovy source code.

                    Mark

                    Comment


                    • #11
                      Depending on how the dependencies amongst sources are arranged, you may be able to organize it to compile.

                      If the groovy has no dependencies on the java you can build the groovy and then depend on it from an ajc compile step that builds the java with aspects and depends on the groovy.

                      If the groovy depends on the java but the java can build without the aspects in the mix, you can build the groovy/java in one step then depend upon it from an ajc step that weaves in the aspects.

                      If the dependencies are more tangled and it'll only work if all built together, unfortunately we have no current solution (yes, it sucks):

                      Groovy-Eclipse is a modified eclipse java compiler that understands groovy. AspectJ is a modified eclipse java compiler that understands AspectJ. We have an open bugzilla to create one modified eclipse compiler that understands java/groovy and AspectJ, but haven't done the work yet ( https://bugs.eclipse.org/bugs/show_bug.cgi?id=287092 )...

                      Andy

                      Comment


                      • #12
                        But even if Eclipse did that, that would have no help to me since I don't use Eclipse as my IDE. IntelliJ here and also run maven on the command line.

                        Mark

                        Comment


                        • #13
                          My initial comments in the previous post were talking about possible maven configurations that might work depending on the dependencies amongst the elements. If that I enhancement I mentioned were implemented, the resultant compiler would be useful not only in Eclipse itself but in maven, for compiling projects involving all three languages where the dependencies were such that they couldn't be compiled as a two stage process. I can't comment on IntelliJ setup unfortunately, but I presume it can call out to maven to do the builds.

                          Andy

                          Comment


                          • #14
                            Just to make sure I am understanding what you mean.

                            Is it something like

                            http://mojo.codehaus.org/aspectj-mav...rectories.html

                            or

                            http://mojo.codehaus.org/aspectj-mav...weaveJars.html

                            Thanks

                            Mark

                            Comment

                            Working...
                            X