I am trying to use Hystrix in my Java Application, its a Non spring java application.
Used following Maven Dependencies in POM to enable Hystrix commands :
<dependency>
<groupId>com.netflix.hystrix</groupId>
<artifactId>hystrix-javanica</artifactId>
<version>1.5.8</version>
</dependency>
<dependency>
<groupId>com.netflix.hystrix</groupId>
<artifactId>hystrix-core</artifactId>
<version>1.5.12</version>
</dependency>
<dependency>
<groupId>com.netflix.rxjava</groupId>
<artifactId>rxjava-core</artifactId>
<version>0.20.7</version>
</dependency>
Used following Dependencies to enable AspectJ :
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.7</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.7</version>
</dependency>
Created a aop.xml in META-INF with following configuration :
<aspectj>
<aspects>
<aspect name="com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect" />
</aspects>
<weaver options="-verbose">
<include within="*" />
</weaver>
</aspectj>
Used Hystrix Command in my Service Class :
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
#Component
#Service
public class TestHystrix
#HystrixCommand(commandKey = "testHystrix", threadPoolKey = "testHystrix", commandProperties = {
#HystrixProperty(name = "hystrix.command.testHystrix.execution.isolation.thread.timeoutInMilliseconds", value = "30") }, threadPoolProperties = {
#HystrixProperty(name = "hystrix.threadpool.testHystrix.maximumSize", value = "3") })
public void testHystrix() {
Added following JVM Argument :
-DWeavingMode=compile
But at both Junit testing and application Runtime, its resulting into following error :
java.lang.NoSuchMethodError: com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect.aspectOf()Lcom/netflix/hystrix/contrib/javanica/aop/aspectj/HystrixCommandAspect;
Please help.
Before asking a question, you should first consult the manual of any tool you like to use. I am just quoting form there:
Aspect weaving
Javanica supports two weaving modes: compile and runtime. (...)
CTW. To use CTW mode you need to use specific jar version: hystrix-javanica-ctw-X.Y.Z. This jar is assembled with aspects compiled with using AJC compiler. If you will try to use regular hystrix-javanica-X.Y.Z with CTW then you get NoSuchMethodError aspectOf() at runtime from building with iajc. Also, you need to start your app with using java property: -DWeavingMode=compile. (...)
So maybe you want to switch your library.
BTW, if you use compile-time weaving (CTW), you should not need aop.xml because AspectJ only uses it for load-time weaving (LTW).
I was able to fix the issue by using following AspectJ Plugin configuration along with above maven dependencies :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.7</version>
<configuration>
<complianceLevel>1.8</complianceLevel>
<source>1.8</source>
<target>1.8</target>
<!-- <showWeaveInfo>true</showWeaveInfo>
<verbose>true</verbose>-->
<Xlint>ignore</Xlint>
<encoding>UTF-8 </encoding>
<!-- Provide the Source information. -->
<!-- <aspectLibraries>
<aspectLibrary>
<groupId>com.netflix.hystrix</groupId>
<artifactId>hystrix-javanica</artifactId>
</aspectLibrary>
</aspectLibraries> -->
<!--Weaving already compiled JAR artifacts -->
<weaveDependencies>
<weaveDependency>
<groupId>com.netflix.hystrix</groupId>
<artifactId>hystrix-javanica</artifactId>
</weaveDependency>
</weaveDependencies>
</configuration>
<executions>
<execution>
<goals>
<!-- use this goal to weave all your main classes -->
<goal>compile</goal>
<!-- use this goal to weave all your test classes -->
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
This plugin will enable Post Compile weaving, for more details refer a very good article # http://www.baeldung.com/aspectj https://www.mojohaus.org/aspectj-maven-plugin/examples/weaveJars.html
With this plugin, aop.xml and -DWeavingMode=compile are also not required
Related
I am fairly new to AOP. I am trying to create annotations in a maven project without Spring using AspectJ. However my the method I am trying to call using the #Aspect is not being called.
This is what my pom looks like :
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>tanvi</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/aspectj/aspectjrt -->
<dependency>
<groupId>aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.5.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/aspectj/aspectjweaver -->
<dependency>
<groupId>aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.5.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.8</version>
<configuration>
<complianceLevel>1.8</complianceLevel>
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
The annotation looks like this :
#Target({ElementType.METHOD})
#Retention(RetentionPolicy.RUNTIME)
public #interface HasAccess {
Access[] accesses();
String message() default "You are not allowed to perform this operation";
}
I created an annotation processor for my annotation :
#Aspect
public class HasAccessAdvice {
// #Before("execution(* *.*(..)) && #annotation(testAnnotation) ")
#Before("execution(* *.*(..)) && #annotation(hasAccess)")
public void myBeforeLogger(JoinPoint joinPoint, HasAccess hasAccess) {
System.out.println("Okay - we're in the before handler...");
System.out.println("The test annotation value is: " + hasAccess.accesses().toString());
Signature signature = joinPoint.getSignature();
String methodName = signature.getName();
String stuff = signature.toString();
String arguments = Arrays.toString(joinPoint.getArgs());
System.out.println("Write something in the log... We are just about to call method: "
+ methodName + " with arguments " + arguments + "\nand the full toString: "
+ stuff);
}
}
I am calling it in this call :
public class TestMe {
#HasAccess(accesses = {Access.CREATE_PURCHASE})
public void createPurchase(BigDecimal bigDecimal) {
System.out.println("create Purchase called");
}
}
I created an aop.xml file and placed it in the same folder as pom.xml.
<aspectj>
<aspects>
<aspect name="HasAccessAdvice"/>
</aspects>
</aspectj>
When I call the method createPurchase, it runs without the #Before method being called first. Please help me with what I am missing. Most of the documentation/answers I found were Spring aligned. Any pointers to any tutorial or even another way of creating simple annotations without Spring would be greatly appreciated.
First, since you are using aop.xml, I assume you want to do load time weaving. See Load Time Weaving docs and docs on different weaving types.
Second, in your aop.xml file, you define which <aspect> to use, but you also need to define which class files / packages you want to weave:
<aspectj>
<aspects>
<aspect name="HasAccessAdvice"/>
</aspects>
<weaver options="-verbose">
<!-- weave anything -->
<include within="*" />
<!-- weave specific packages only -->
<include within="my.package..*" />
</weaver>
</aspectj>
Either use "*" to run your aspect on any classes or replace my.package with the package of TestMe. Note that double-dot .. includes sub-packages too.
Also note that <aspect name="..."> asks for fully-qualified Aspect-name with package. Did you create HasAccessibleAdvice in default-package? Add your package otherwise.
Third, aop.xml must be readable in META-INF/aop.xml on your classpath.
If you are running your test via CLI (using java -javaagent...), check your classpath settings (-cp).
If you are writing JUnit tests, you can put META-INF/aop.xml in src/test/resources and adjust the <build><plugins>-section of your pom.xml to include the load time weaver like this:
<properties>
<aspectj.version>1.8.9</aspectj.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.9</version>
<configuration>
<argLine>
-javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar
</argLine>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
I'm trying to use some nifty lazy logging tricks in my logging layer but AspectJ is choking on it. I have a facade in front of log4j. Here's the code:
public void debug ( Supplier<String> message )
{
if( isDebugEnabled() )
{
debug( message.get() );
}
}
The error:
[ERROR] The type java.util.function.Supplier cannot be resolved. It is indirectly referenced from required .class files
/home/Build/src/Core/Database/src/com/BasicDao.java:1006
LOGGER.debug( "Retry number: "+retryCount+"DB Lock Conflict, sleeping "+retrySleepTime );
Here's my pom bits:
<plugin>
<!-- This plugin integrates aspectj into our build cycle -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.7</version>
<configuration>
<complianceLevel>1.8</complianceLevel>
<source>1.8</source>
<target>1.8</target>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.8.5</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
And:
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.5</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.5</version>
</dependency>
Other interesting facts are that this compiles fine within Eclipse, but I get this error when running mvn package from a Linux command line.
Upon further trial/error we have discovered that if we manually set JAVA_HOME to point to Java 8 then it compiles. It looks like AspectJ requires your JAVA_HOME to point to the right version of Java. In the main pom we are directing maven to use the specific version of Java with:
<executable>${JAVA_1_8_HOME}/bin/javac</executable>
<jvm>${JAVA_1_8_HOME}/jre/bin/java</jvm>
Neither of those seemed to work with the aspectj-maven-plugin configuration.
I've configured weaving third party jar with maven plugin aspectj-maven-plugin.
<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>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<!--<proceedOnError>true</proceedOnError>-->
<weaveDependencies>
<weaveDependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
</weaveDependency>
</weaveDependencies>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
There is a problem with references to missing java classes. Quartz jar has some integration with JMS but my application doesn't use JMS so those quartz files are never loaded.
I've found a crutch with proceedOnError = true but I think due errors spring injection into aspect annotated class stops workings.
shade-maven-plugin doesn't fit here because it could be triggered by package phase only and aspectj launches on compile one.
[INFO] --- aspectj-maven-plugin:1.4:compile (default) # aspectj-demo ---
[ERROR] can't determine implemented interfaces of missing type javax.servlet.ServletContextListener
when processing declare parents org.quartz.ee.servlet.QuartzInitializerListener
when processing type mungers
when weaving
when batch building BuildConfig[null] #Files=5 AopXmls=#0
[Xlint:cantFindType]
[ERROR] can't determine implemented interfaces of missing type javax.servlet.http.HttpServlet
when processing declare parents org.quartz.ee.servlet.QuartzInitializerServlet
when processing type mungers
when weaving
when batch building BuildConfig[null] #Files=5 AopXmls=#0
[Xlint:cantFindType]
Any Maven coordinate listed in weaveDependencies must also be mentioned as a normal dependency. Based on the download page, you will need to have the following dependencies defined under <build>:
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.1.6</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz-oracle</artifactId>
<version>2.1.6</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz-weblogic</artifactId>
<version>2.1.6</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz-jboss</artifactId>
<version>2.1.6</version>
</dependency>
Then under your configuration section for the aspectj-maven-plugin plugin, you can reference the JAR file that contains the aspects that you want to weave:
<weaveDependencies>
<weaveDependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
</weaveDependency>
</weaveDependencies>
You may also need to use the 1.2 version of the aspectj-maven-plugin. Supposedly there is a bug in 1.4 about "declare parents" (but not sure if that's been fixed), and early versions of 1.3 suffered from the bug known as MASPECTJ-90.
MY aspect works great from Eclipse with AspectJ plugin, however if I try to use it with Maven I get .... nothing.
I tried this http://mojo.codehaus.org/aspectj-maven-plugin/includeExclude.html
I add loggin in my aspect and I try to test it with junit test, but when I run
mvn clean
mvn test
I get...
[INFO] [aspectj:compile {execution: default}]
But i dont see logging in test
If I do compiling in Eclipse it works find, but Id like it to be IDE Independent(so I could use it with Hudson)
P.S. I use .aj file for Aspect
I tried to Google it, but I cant find any working example.
Without seeing your POM it's hard to say, one thing to check is that Maven expects your aspects to be under src/main/aspect rather than src/main/java by default.
You also need to ensure the aspectj runtime library is on your classpath (in Eclipse it is included by the AJDT classpath container.
For example (from the plugin documentation):
<project>
...
<dependencies>
...
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.6.2</version>
</dependency>
...
</dependencies>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal> <!-- use this goal to weave all your main classes -->
<goal>test-compile</goal> <!-- use this goal to weave all your test classes -->
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
<build>
...
</project>
If neither of these work, can you post your pom contents? It might help to identify the problem.
Update 5: I've downloaded the latest Spring ToolsSuite IDE based on the latest Eclipse. When I import my project as a Maven project, Eclipse/STS appears to use the Maven goals for building my project. This means AspectJ finally works correctly in Eclipse.
Update 4: I have ended up just using Maven + AspectJ plugin for compile-time weaving, effectively bypassing Eclipse's mechanism.
Update 3: It seems AspectJ's Eclipse plug-in breaks Eclipse's ability to correctly Publish to Tomcat. Only by removing the AspectJ capability on a project can I get it to properly Publish again. Very annoying.
Update 2: I have this now working in Eclipse. It makes me very uncomfortable to say this, but I have no idea how I got it working from either Eclipse or Maven builds. It appears to be a compile issue rather than a run-time issue.
Update 1: It appears I've gotten this to work via Maven builds, but I have no idea how. Eclipse still doesn't work. The only thing I changed in the pom.xml was adding these (insignificant?) configuration parameters:
<source>1.6</source>
<complianceLevel>1.6</complianceLevel>
<verbose>true</verbose>
<showWeaveInfo>true</showWeaveInfo>
<outxml>true</outxml>
I'm actually worried that I have a repeat of this problem, where everything works inconsistently. I will keep this question updated as I learn more.
With regards to Eclipse, I made some progress by taking the binary aspects I wish to weave - in this case spring-aspects.jar - and copying it out of my classpath. I then add this now external jar to my Aspect Path. After doing this, Eclipse properly shows me AspectJ markers in my code. It's annoying that I can't just leave spring-aspects.jar in my Java Build Path which is maintained by Maven for me via the Maven plug-in. For some reason, however, the AspectJ plug-in doesn't see the binary aspects unless they're explicitly added to the Aspect Path.
Original Post: #Configurable is a Spring annotation that allows dependencies to be injected into objects instantiated external to Spring (for example, by Hibernate or some Factory class).
I was using this annotation previously with load-time weaving and it mostly worked. Occasionally I would boot up and nothing would get injected. This issue spawned this StackOverflow question. There weren't many answers, but most suggested that I try compile-time weaving instead due to greater reliability.
I installed the AspectJ plug-in for Eclipse and Maven. Both of these produce what appears to be properly compiled classes. I've opened up one of the classes in a text editor before AspectJ compilation and found no references to AspectJ. I opened it up after AspectJ compilation and both Eclipse and Maven generated versions have a reference to org.aspectj.weaver.MethodDeclarationLineNumber. This is why I assume it's being properly compiled. The problem is that once deployed, no dependencies get injected.
My Spring applicationContext.xml does include the following:
<context:spring-configured />
<context:component-scan base-package="com.myapp" />
Is the above all that's needed for classes marked #Configurable to have DI done? During the conversion from load-time weaving to compile-time weaving, I removed META-INF/aop.xml, <context:load-time-weaver /> from my applicationContext.xml, and Spring's Tomcat weaver from my context.xml.
How can I investigate this problem further? What are possible causes?
It works for us on maven using compile time weaving, try adding the following plugins:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerVersion>1.6</compilerVersion>
<fork>true</fork>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<executions>
<execution>
<id>compile</id>
<configuration>
<source>1.6</source>
<target>1.6</target>
<verbose>false</verbose>
<outxml>true</outxml>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<configuration>
<source>1.6</source>
<target>1.6</target>
<verbose>false</verbose>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.6.4</version>
</dependency>
</dependencies>
</plugin>
Its done as two separate execution steps to allow you to add different aspect libraries for unit testing and compilation.
You'll also need the following dependency added for the spring-aspects library:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<scope>compile</scope>
</dependency>
I successfully configured load-time weaving in my app, if this is an alternative for you.
My environment:
JDK-1.6
Spring-2.5.6
JPA with eclipselink-1.1.0
Configuration details:
Spring XML configuration:
<context:annotation-config/>
<context:spring-configured/>
<context:load-time-weaver/>
<bean id="baseEntity" class="package.name.BaseEntity" scope="prototype">
<property name="historyHandler" ref="historyHandler" />
</bean>
<bean id="historyHandler" class="package.name.HistoryJpaHandler" scope="prototype">
<property name="historyDao" ref="historyDao" />
</bean>
<bean id="historyDao" class="package.name.HistoryJpaDao">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
Spring annotations
#Configurable("baseEntity")
public abstract class BaseEntity
#Configurable("historyHandler")
public class HistoryJpaHandler extends SessionEventAdapter implements HistoryHandler
Java VM Parameter
<JAVA_HOME>/bin/java -javaagent:/full/path/to/spring-agent-2.5.6.jar
Instances of historyHandler and baseEntitty are created by ecliselink. historyHandler in baseEntitty and historyDao in historyHandler is set by load-timeweaving.
You can set the VM Parameter in Eclipse run configuration or in Tomcats catalina.sh/bat.
making a field of a #configurable class Autowired throws NullPointerException if you do not configure your spring properly for this annotation.
follow these steps to make #configurable annotations work properly
This method is called AspectJ build time weaving to inject spring beans to your non-spring-made classes.
First step is to install these plugins in eclipse:
From these two update sites install whatever eclipse suggests:
http://download.eclipse.org/tools/ajdt/43/update
http://dist.springsource.org/release/AJDT/configurator/
After installing,right-click on project and Do:
Configure > Convert to Aspectj
Maven > Update
Next, you need to add these to your pom.xml:
Under Dependencies Add:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>4.0.2.RELEASE</version>
</dependency>
Under Plugins Add:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.5</version>
<configuration>
<showWeaveInfo>true</showWeaveInfo>
<source>1.7</source>
<target>1.7</target>
<Xlint>ignore</Xlint>
<complianceLevel>1.7</complianceLevel>
<encoding>UTF-8</encoding>
<verbose>false</verbose>
<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>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.7.0</version>
</dependency>
</dependencies>
</plugin>
Important: DO NOT use any <pluginManagment> tag under <build> tag.
your pom.xml needs to be something like this:
<project ....>
....
<dependencies>
<dependency>
....
</dependency>
....
</dependencies>
<build>
<plugins>
<plugin>
....
</plugin>
....
</plugins>
</build>
</project>
finally add <context:spring-configured /> to your spring application context config file.
Now you can annotate a POJO class as #Configurable and inject spring beans in it using #Autowired annotation. this way whenever you make a new instance of that POJO it will be configured (e.g. injected with dependencies) automatically.
As far as your Eclipse classpath issues are concerned, you might find this useful.
The m2eclipse plugin has an optional AJDT integration. The integration reads the aspectLibraries section of the aspectj-maven-plugin's configuration, and contributes the jars to Eclipse's Aspect Path.