Hi,
I am new in Spring. While trying to create aspect using AspectJ annotation, I am getting following error.
My configuration file is as follows:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       [url]http://www.springframework.org/schema/beans/spring-beans-2.0.xsd[/url] 
       [url]http://www.springframework.org/schema/aop[/url]
       http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

    <bean id="audience" 
        class="src.com.spring.Audience"/>
    <bean id="steve" class="src.com.spring.Juggler">
        <property name="beanBags">
            <list>
                <value> "1" </value>
                <value> "3" </value>
            </list>
        </property>
    </bean>
    <aop:aspectj-autoproxy />
</beans>

the advice class is as follows :

@Aspect
public class Audience1 {
    public Audience1() {}

    @Pointcut("execution(* *.perform(..))")
    public void performance() {}

    @Before("performance()")
    public void takeSeats() {
        System.out.println("The audience is taking their seats.");
    }

    @Before("performance()")
    public void turnOffCellPhones() {
        System.out.println("The audience is turning off their cellphones");
    }
    @AfterReturning("performance()")
    public void applaud() {
        System.out.println("CLAP CLAP CLAP CLAP CLAP");
    }
    @AfterThrowing("performance()")
    public void demandRefund() {
        System.out.println("Boo! We want our money back!");
    }
}

When running the program I am getting the following error :

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'steve' defined in file [C:\Documents and Settings\eclipse3.2\nam-main-workspace\SpringPractice\src\com\spring\spring-test.xml]: Initialization of bean failed; nested exception is java.lang.IllegalAccessError: tried to access method org.aspectj.weaver.tools.PointcutParser.<init>()V from class org.aspectj.weaver.reflect.InternalUseOnlyPointcutParser
Caused by: java.lang.IllegalAccessError: tried to access method org.aspectj.weaver.tools.PointcutParser.<init>()V from class org.aspectj.weaver.reflect.InternalUseOnlyPointcutParser
    at org.aspectj.weaver.reflect.InternalUseOnlyPointcutParser.<init>(InternalUseOnlyPointcutParser.java:22)
    at org.aspectj.weaver.reflect.Java15ReflectionBasedReferenceTypeDelegate.getDeclaredPointcuts(Java15ReflectionBasedReferenceTypeDelegate.java:249)
    at org.aspectj.weaver.ReferenceType.getDeclaredPointcuts(ReferenceType.java:526)
    at org.aspectj.weaver.ResolvedType$7.get(ResolvedType.java:465)
    at org.aspectj.weaver.Iterators$3$1.hasNext(Iterators.java:118)
    at org.aspectj.weaver.Iterators$3.hasNext(Iterators.java:128)
    at org.aspectj.weaver.ResolvedType.findPointcut(ResolvedType.java:476)
    at org.aspectj.weaver.patterns.ReferencePointcut.resolveBindings(ReferencePointcut.java:151)
    at org.aspectj.weaver.patterns.Pointcut.resolve(Pointcut.java:194)
    at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:313)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:189)

I am not getting any hints/clue how to resolve the problem.
Thanks in advance.

Recommended Answers

All 2 Replies

Please check
1.if your spring application is able to locate your context.property file

2.is property declared ? ,and check getter and setter method for all property..

musthafa thanks for reply.
I chekced the context file and it is correct.
I also checked the bean class. the setters and getters defined properly.
The same program is running successfully when autoproxying using Spring's Aspects, but not running when using @AspectJ autoproxying.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.