Here's the configuration:
Spring context:
Aspect class...Defines simple package pointcut:Code:<aop:aspectj-autoproxy /> <bean id="simpleMethodTraceAspect" class="com.company.swd.common.view.util.SimpleMethodTraceAspect"> </bean> <bean id="ApEngineListener" class="com.company.swd.apengine.core.ApEngineListener" init-method="init" destroy-method="dispose"> <property name="ActivityPlanManager"> <ref bean="ActivityPlanManager"/> </property> </bean> <bean id="ActivityPlanManager" class="com.company.swd.apengine.core.ActivityPlanManager" destroy-method="shutdown" init-method="init" scope="singleton"> </bean>
Advice Class:Code:@Aspect public class SystemArchitectureAOP { @Pointcut("within(com.company.swd.apengine..*)") public void inApengine() {} }
Here's the problem: Spring is trying to inject the ActivityPlanManager bean into the ApEngineListener bean, but it is causing a TypeMismatchException during context startup because the Spring context is seeing the ActivityPlanManager bean as one of those proxy types:Code:@Aspect public class SimpleMethodTraceAspect implements Ordered { private Log logger = LogFactory.getLog(SimpleMethodTraceAspect.class); private int order = 1; public int getOrder() { return this.order; } public void setOrder(int order) { this.order = order; } @Around("com.company.swd.common.view.util.SystemArchitectureAOP.inApengine()") public Object trace(ProceedingJoinPoint pjp) throws Throwable { logger.info("Target: " + pjp.getTarget()); logger.info("Signature Name: " + pjp.getSignature().getName()); try { logger.info("UserName: " + SecurityAssociation.getPrincipal().getName()); } catch (RuntimeException e) { // just catch } return pjp.proceed(); } }
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'ApEngineListener' defined in ServletContext resource [/WEB-INF/apEngineContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateExcep tion; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy241] to required type [com.company.swd.apengine.core.ActivityPlanManager] for property 'ActivityPlanManager'; nested exception is java.lang.IllegalArgumentException: No matching editors or conversion strategy found
Caused by:
org.springframework.beans.PropertyBatchUpdateExcep tion; nested PropertyAccessException details (1) are:
PropertyAccessException 1:
org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy241] to required type [com.company.swd.apengine.core.ActivityPlanManager] for property 'ActivityPlanManager'; nested exception is java.lang.IllegalArgumentException: No matching editors or conversion strategy found
Caused by:
java.lang.IllegalArgumentException: No matching editors or conversion strategy found
Why would the ActivityPlanManager bean be a $Proxy241 type? Maybe it's a load order issue, where Spring hasn't finished it's AOP magic yet on the ActivityPlanManager bean?
Any help would be appreciated.


Reply With Quote