Announcement Announcement Module
No announcement yet.
Adding spring-aspects causes compilation errors Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Adding spring-aspects causes compilation errors

    Hey all, I've been using Spring and Spring AOP (dynamic proxies) for a long time, but I'm just now looking at tossing some bytecode weaving into the mix. Right now, I'm trying to get a basic @Configurable object to work--i.e. be injectable by Spring when instantiated outside of Spring. I have a simple project set up using Maven and the aspectj-maven-plugin for build-time weaving. I have two simple classes. One has a main method, and one is an aspect with a pointcut that prints to stdout when that main method executes. I can compile and run this simple example just fine. As soon as I add org.springframework:spring-aspects--it seems to need to be an "aspectLibrary" in the plugin's configuration as well as a project dependency--I get this compilation error:
    [ERROR] can't determine superclass of missing type org.springframework.transaction.interceptor.Transa ctionAspectSupport
    when batch building BuildConfig[null] #Files=2 AopXmls=#0

    That looks to me like something from spring-tx, so I add that as a dependency, and then I get:
    [ERROR] can't determine annotations of missing type javax.persistence.Entity
    when weaving type
    when weaving classes
    when weaving
    when batch building BuildConfig[null] #Files=2 AopXmls=#0

    After I add org.hibernate.javax.persistence:hibernate-jpa-2.0-api, it's back to working. Surely I'm doing something wrong here. Do I seriously have to have spring-tx and JPA on my classpath just to be able to use @Configurable?

  • #2
    I've found that there's a compiler option to change the level of "can't find type" errors. It seems that it can only be set using the aspectj compiler's -Xlintfile option and providing a properties file that overrides the defaults. You add the property cantFindType = warning, and it changes from a compiler error to a warning, letting the compilation go ahead. Does anyone know how to do something like this in the aspectj maven plugin? It seems to only support "-Xlint", which only seems to be able to set coarse-grained error checking options and not specifically change the level of a particular check.


    • #3