Announcement Announcement Module
Collapse
No announcement yet.
TypeMismatchException Problem...AOP Load Order Issue? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • TypeMismatchException Problem...AOP Load Order Issue?

    Here's the configuration:

    Spring context:

    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>
    Aspect class...Defines simple package pointcut:
    Code:
    @Aspect
    public class SystemArchitectureAOP {
    	  @Pointcut("within(com.company.swd.apengine..*)")
    	  public void inApengine() {}
    }
    Advice Class:
    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();
    	}
    
    }
    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:

    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.

  • #2
    Are you programming to interfaces? Might want to check this out.
    http://www.cwinters.com/news/display/3410

    Also this might help.
    http://forum.springframework.org/showthread.php?t=28216
    Last edited by karldmoore; Dec 9th, 2006, 03:02 PM.

    Comment


    • #3
      The proxy-target-class="true" addition worked. Thanks!

      Comment

      Working...
      X