Announcement Announcement Module
Collapse
No announcement yet.
Strange behaviour of point-cut with annotation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Strange behaviour of point-cut with annotation

    Hello.
    I have my own annotation:
    Code:
    @Retention(value=RetentionPolicy.RUNTIME)
    public @interface ExceptionalController
    {
        String test() default "test";
    }
    and aspect in spring context:
    Code:
        <aop:config>
            <aop:aspect id="exceptionAspect" ref="exceptionInterceptor">
                <aop:pointcut id="controllers" expression="@target(ExceptionalController)"/>
                <aop:around method="interceptException" pointcut-ref="controllers"></aop:around>
            </aop:aspect>
        </aop:config>
    I try to deploy my project to Tomcat without labeling anything by my annotation, and get following error during servlet initialization:

    Code:
    8.03.2009 0:02:50 org.springframework.web.context.ContextLoader initWebApplicationContext
    SEVERE: Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'actionService' defined in ServletContext resource [/WEB-INF/applicationContext-services.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
    PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.util.LinkedHashMap] to
    required type [java.util.Map] for property 'actions'; nested exception is java.lang.ClassCastException: $Proxy21 cannot be cast to actions.AbstractAction
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java
    Class AbstractAction is my own class without any annotation or Spring depended features. It is only declared as bean.
    What's I do wrong?
    And is there any possibility to use annotations for Spring AOP if I want to use Spring Web MVC controllers as target objects? I think it could be some difficulties because of using proxies and reflection in Web MVC. Am I right?
    What is the best way for using aspects for my case?
Working...
X