Dear All,
I have a rather frustrating problem with running Spring integration tests with maven surefire plugin, using the TestContexts framework. The problem is typical based on the google results: I've tried to inject repositories into domain object by using LTW. It all works nicely when running the application, but the DAO is not injected when I try to run the integration tests. I've carefully followed the instructions to configure the surefire plugin, but the LTW feature still doesn't work.
Here is my domain object:
and my Spring config:Code:@Entity @Table(name = "JOB_USER") @Configurable("user") public class User extends BaseEntity { private static final long serialVersionUID = -6863852659859379841L; @Transient private transient UserDao userDao; @Required public void setUserDao(final UserDao userDao) { this.userDao = userDao; } [...] }
Maven surefire plugin is configured like this:Code:<context:load-time-weaver/> <context:spring-configured/> <context:annotation-config/> <bean id="userDao" class="hu.jobportal.domain.user.dao.jpa.JpaUserDao"/> <bean id="user" class="hu.jobportal.domain.user.model.User" scope="prototype"> <property name="userDao" ref="userDao"/> </bean>
The aop.xml is this:Code:<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <forkMode>once</forkMode> <argLine> -javaagent:${settings.localRepository}/org/springframework/spring-instrument/${spring.version}/spring-instrument-${spring.version}.jar </argLine> <useSystemClassLoader>true</useSystemClassLoader> </configuration> </plugin>
I'm using 3.0.0.RC3 version, but the same applies to 2.5.6. In the logs I can see that the AspectJ weaver is loaded and it prints a lot of debug messages about not weaving and weaving objects, but my User object is not there.Code:<?xml version="1.0" encoding="UTF-8"?> <aspectj> <weaver options="-verbose -debug -showWeaveInfo"> <include within="hu.jobportal..*"/> </weaver> </aspectj>
The annoying thing is that it works perfectly when I bootstrap the ApplicationContext from a main method and instantiate a User object with new.
Thanks in advance,
Mark


Reply With Quote
