Results 1 to 3 of 3

Thread: Adding spring-aspects causes compilation errors

  1. #1

    Default 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
    [Xlint:cantFindType]

    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 com.bar.SomeBean
    when weaving classes
    when weaving
    when batch building BuildConfig[null] #Files=2 AopXmls=#0
    [Xlint:cantFindType]

    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. #2

    Default

    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. #3
    Join Date
    Jul 2010
    Posts
    18

    Default

    Code:
    <build>
    		<plugins>
    			<plugin>
    
    				<groupId>org.codehaus.mojo</groupId>
    				<artifactId>aspectj-maven-plugin</artifactId>
    				<version>1.4</version>
    				<dependencies>
    					<dependency>
    						<groupId>org.aspectj</groupId>
    						<artifactId>aspectjrt</artifactId>
    						<version>${aspectj.version}</version>
    					</dependency>
    					<dependency>
    						<groupId>org.aspectj</groupId>
    						<artifactId>aspectjtools</artifactId>
    						<version>${aspectj.version}</version>
    					</dependency>
    				</dependencies>
    				<executions>
    					<execution>
    						<goals>
    							<goal>compile</goal>
    						</goals>
    					</execution>
    				</executions>
    				<configuration>
                                            <Xlint>warning</Xlint>
    					<aspectLibraries>
    						<aspectLibrary>
    							<groupId>org.springframework</groupId>
    							<artifactId>spring-aspects</artifactId>
    						</aspectLibrary>
    					</aspectLibraries>
    					<source>1.6</source>
    					<target>1.6</target>
    				</configuration>
    
    			</plugin>
    		</plugins>
    	</build>

Posting Permissions

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