I have some working aspects and I wanted to inject a factory object into one of them. These aspects have been working great and the factory object is injected into other non-aspect classes without any problems. I'm getting errors when trying to inject the object into an aspect. Here is what my code looks like below and the error I'm getting is at the bottom. I've been beating my head against a wall all day, pouring through forum posts and I can't figure out what I'm doing wrong. Hopefully of you will be able to help me.
aop.xml
application-context.xmlCode:<?xml version="1.0" encoding="UTF-8"?> <aspectj> <aspects> <!-- Declare aspects to be used by the service --> <aspect name="com.xyz.myservice.aspects.LoggingAspect" /> </aspects> <weaver options="-verbose -showWeaveInfo"> <include within="com.xyz.myservice..*" /> <!-- REQUIRED --> </weaver> </aspectj>
LoggingAspect.javaCode:...... ...... <context:load-time-weaver aspectj-weaving="on"/> <bean id="LoggingAspect" class="com.xyz.myservice.aspects.LoggingAspect" factory-method="aspectOf"> <property name="someFactory" ref="SomeFactory" /> </bean>
When starting the JVM I'm giving it the following arguments:Code:@Aspect public class LoggingAspect{ private SomeFactory someFactory; public void setSomeFactory(SomeFactory someFactory) { this.someFactory = someFactory; } followed by pointcuts and advice...
-javaagent:myPath/lib/spring-instrument-3.0.jar />
-javaagent:myPath/lib/aspectjweaver-1.6.12.jar/>
The server output looks like this.
1) AspectJ comes up and registers the aspects I have defined in aop.xml
2) I see lots of output for the weave info of the classes it's weaving during load time.
3) AspectJ finishes and the server starts up.
4) As soon as the server starts it fails trying to create the LoggingAspect bean. The error looks like this.
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'LoggingAspect' defined in file [/path/to/service/application-context.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'someFactory' of bean class [com.xyz.myservice.aspects.LoggingAspect]: Bean property 'someFactory' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
The bean has a setter and it's of the correct type. Any idea what I might be doing wrong here or things I can try?
Thanks,
Aaron


Reply With Quote