I have a multi-module Maven project where I am using @Configurable
and @Autowired
to inject dependencies (CTW). The project have been developed on OS X and Win8, and now I am trying to get it to work with Linux (Ubuntu 14.04). Maven runs just fine but when running the application locally through IntelliJ, the autowired fields are null.
I'm running Tomcat 7 but I have tried with Jetty and I get the same error. Also, @Autowired
in @Component
annotated classes works fine. Since the project is currently running on both OS X and Win8 using the same(?) IntelliJ configuration, it feels like I've missed something when setting up the environment. Any ideas?
Example class
@Configurable
public class TestClass {
@Autowired
private MyRepository repository;
...
}
Application context
<context:spring-configured/>
<context:component-scan base-package="com.mycompany"/>
<aop:aspectj-autoproxy/>
aspectj-maven-plugin
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>${aspectj.maven.plugin.version}</version>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
<configuration>
<complianceLevel>${java.version}</complianceLevel>
<source>${java.version}</source>
<target>${java.version}</target>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
AspectJ weaveInfo
[INFO] Extending interface set for type 'com.mycompany.TestClass' (TestClass.java) to include 'org.springframework.beans.factory.aspectj.ConfigurableObject' (AnnotationBeanConfigurerAspect.aj)
[INFO] Join point 'initialization(void org.springframework.beans.factory.aspectj.ConfigurableObject.<init>())' in Type 'com.mycompany.TestClass' (TestClass.java:15) advised by before advice from 'org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect' (spring-aspects-3.2.1.RELEASE.jar!AbstractDependencyInjectionAspect.class:78(from AbstractDependencyInjectionAspect.aj)) [with runtime test]
[INFO] Join point 'initialization(void org.springframework.beans.factory.aspectj.ConfigurableObject.<init>())' in Type 'com.mycompany.TestClass' (TestClass.java:15) advised by afterReturning advice from 'org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect' (spring-aspects-3.2.1.RELEASE.jar!AbstractDependencyInjectionAspect.class:87(from AbstractDependencyInjectionAspect.aj)) [with runtime test]
[INFO] Join point 'initialization(void com.mycompany.TestClass.<init>())' in Type 'com.mycompany.TestClass' (TestClass.java:15) advised by afterReturning advice from 'org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect' (spring-aspects-3.2.1.RELEASE.jar!AbstractDependencyInjectionAspect.class:87(from AbstractDependencyInjectionAspect.aj)) [with runtime test]
Update 1
The repositories are Spring Data repositories with @Repository
-annotation. However, none of the @Component
, @Repository
, @Service
are autowired into the @Configurable
class but they do successfully autowire into @Component
-annotated classes.
@Repository
public interface MyRepository extends PagingAndSortingRepository<Person, String>
Update 2 When switching to LTW, the autowiring is successful and the application seems to work as intended. On the other hand, now TomcatInstrumentableClassLoader complains that it can't determine implemented interfaces of missing type com.google.gwt.*