Announcement Announcement Module
Collapse
No announcement yet.
addition of @Aspect causes UnsafeObjectFieldAccessorImpl Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • addition of @Aspect causes UnsafeObjectFieldAccessorImpl

    Hello,

    I am experimenting with AOP, I have created an annotated Apect class :

    Code:
    @Aspect
    public class ProcessManager {
    
    	@After("execution (* *.*(..))")
    	public void startProces(JoinPoint joinPoint) {
    		System.out.println(joinPoint.getSignature().getName());
    	}
    }
    And my beans file starts off like this:


    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- 
    These spring beans contain ONLY production spring beans and contain ALL spring beans 
    used in the system.
     -->
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    		xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"
    		xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee"
    		xmlns:tx="http://www.springframework.org/schema/tx"
    		xsi:schemaLocation="
    			http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
    			http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    			http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
    			http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
    			http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
    	
    	<context:annotation-config />
    	
    	<aop:aspectj-autoproxy />
    	
    	
    	<bean id="processManager" class="com.metadatatechnology.sdmxConsole.logging.ProcessManager" />
    
    .....
    </beans>
    Unfortunately when I add the ProcessManager class I get the following error:
    Code:
    Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'endpointConnectionManager': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.metadatatechnology.sdmxConsole.manager.impl.SdmxConsoleSessionManager com.metadatatechnology.sdmxConsole.manager.impl.AbstractConsoleManager.sessionManager; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sdmxConsoleSessionManager': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.metadatatechnology.sdmxConsole.manager.impl.SdmxConsoleSecuirtyManager com.metadatatechnology.sdmxConsole.manager.impl.SdmxConsoleSessionManager.sdmxConsoleSecurityManager; nested exception is java.lang.IllegalArgumentException:
    java.lang.IllegalArgumentException
    	at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
    	at java.lang.reflect.Field.set(Field.java:656)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:503)
    	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:283)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1055)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:825)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:767)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:685)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnn
    ......
    I have no idea what is causing this, the application works fine without the aspect - it is the addition of @After("execution (* *.*(..))") that causes it to fail.

    I was using spring 2.5.6, but have now upgraded to 3.0.2 .RELEASE to try and solve the problem.

    I am using spring security as well and spring flex, I have the following spring jars on my class path

    Code:
    spring-aop 3.0.1.RELEASE
    spring-asm 3.0.1.RELEASE
    spring-aspeacts 3.0.1.RELEASE
    spring-beans 3.0.1.RELEASE
    spring-context 3.0.1.RELEASE
    spring-context-support 3.0.1.RELEASE 
    spring-core 3.0.1.RELEASE
    spring-expression 3.0.1.RELEASE
    spring-flex 1.0.2.RELEASE
    spring-jdbc 3.0.1.RELEASE
    spring-orm 3.0.1.RELEASE
    spring-security-acl 3.0.2.RELEASE
    spring-security-config 3.0.2.RELEASE
    spring-security-core 3.0.2.RELEASE
    spring-security-openid 3.0.2.RELEASE
    spring-security-taglibs 3.0.2.RELEASE
    spring-security-web 3.0.2.RELEASE
    spring-test 3.0.1.RELEASE
    spring-tx 3.0.1.RELEASE
    spring-web 3.0.1.RELEASE
    If anyone can help I would be very very very happy....

    Thanks

  • #2
    Ok fixed problem..In one part of the code I was autowiring a Concrete class rather then an Interface.

    Comment

    Working...
    X