Announcement Announcement Module
Collapse
No announcement yet.
warning no match for this type name: sbt...SomeBean [Xlint:invalidAbsoluteTypeName] Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • warning no match for this type name: sbt...SomeBean [Xlint:invalidAbsoluteTypeName]

    I never used Spring AOP and trying to configure my first bean. It seems that I configured it properly, but I get an exception that the bean is not found.

    My aspect is -

    Code:
        @Aspect
        @Component
        public class IdentificationAspect {
    
            @Before("execution(* ru.sbt.filial.cards.aspect.SomeBean.*(..))")
            public void logBefore(JoinPoint joinPoint) throws Throwable {
    
                System.out.println("logBefore() is running!");
                System.out.println("hijacked : " + joinPoint.getSignature().getName());
                System.out.println("******");
            }
        }
    And my bean that AOP doesn't find is -

    Code:
        package ru.sbt.filial.cards.aspect;
     
        import org.springframework.stereotype.Component;
     
        @Component
        public class SomeBean {
     
            public void printSmth() {
               System.out.println("!!!!!!!!!!!");
            }
      
        }

    I've got the following exception -

    Code:
        Caused by: java.lang.IllegalArgumentException: warning no match for this type name: ru.sbt.filial.cards.aspect.SomeBean [Xlint:invalidAbsoluteTypeName]
                        at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:301)
                        at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:207)
                        at org.springframework.aop.aspectj.AspectJExpressionPointcut.getFallbackPointcutExpression(AspectJExpressionPointcut.java:358)
                        at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:255)
                        at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:208)
                        at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:262)
                        at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:294)
                        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117)
                        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87)
                        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68)
                        at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:356)
                        at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:319)
                        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:412)
                        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.postProcessObjectFromFactoryBean(AbstractAutowireCapableBeanFactory.java:1629)
                        at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:162)
                        ... 165 more
    I have following maven dependencies -

    Code:
                      <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-aop</artifactId>
                        <version>3.2.0.RELEASE</version>
                      </dependency>
                      <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
                        <version>1.7.3</version>
                      </dependency>
                      <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjrt</artifactId>
                        <version>1.7.3</version>
                      </dependency>

    And my spring applicationContext.xml configuration is -


    Code:
        <?xml version="1.0" encoding="UTF-8" standalone="no"?>
        <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:mvc="http://www.springframework.org/schema/mvc"
           xmlns:aop="http://www.springframework.org/schema/aop"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
                                 http://www.springframework.org/schema/beans/spring-beans.xsd
                                 http://www.springframework.org/schema/mvc
                        http://www.springframework.org/schema/mvc/spring-mvc.xsd
                                 http://www.springframework.org/schema/context
                        http://www.springframework.org/schema/context/spring-context-3.2.xsd
                                 http://www.springframework.org/schema/aop
                        http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
    
        <mvc:annotation-driven/>
        <aop:aspectj-autoproxy/>
    
        <context:component-scan base-package="ru.sbt.filial.cards.aspect"/>
    
        <bean id="someBean" class="ru.sbt.filial.cards.aspect.SomeBean">
        </bean>
    
    </beans>


    I lso tried to annotate different ways - if I don't specify the bean i.e. write -

    Code:
        @Before("execution(* ru.sbt.filial.cards.aspect.*.*(..))")
    instead

    Code:
        @Before("execution(* ru.sbt.filial.cards.aspect.SomeBean.*(..))")
    I have no error on loading, but aop method is not invoked.

    I also tried to annotate like this

    Code:
        @Before("this(ru.sbt.filial.cards.aspect.SomeBean) and execution(* printSmth(..))")

    but with same result - no match for this type name.
    Does anybody have ideas?
    Last edited by veterr82; Feb 17th, 2014, 01:54 AM.

  • #2
    We are currently in the process of moving to stackoverflow.com for our forums. If you're still having this issue please consider asking it again at http://stackoverflow.com using the #spring tag. If you do post it there, please reply here with the link. Thanks!
    Last edited by Andrei Stefan; Jun 19th, 2014, 10:32 AM.

    Comment

    Working...
    X