Hello,
I use an aspect that was compiled by aspect-j compiler
however I want to use aspectj-autoproxy in same project
I noticed is that when aspect is compiled with aspectj compiler the aspectj-autoproxy stops working.
Here is the code:
Why aspectj-autoproxy doesn't work when aspect was compiled with aspectj and how to fix it?Code:/* Foo.java */Divorce Attorney Denver CO Thailand holiday packages public interface Foo { void foo();home security services estojo original rolex } /* FooImpl.java */ public class FooImpl implements Foo { public void foo() { } } /* FooAspect.java */ import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; @Aspect public class FooAspect { @Around("execution(void *.foo())") public Object throwException(ProceedingJoinPoint pjp) { throw new RuntimeException(); } } /** FooTest.java */ import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "/application-context.xml") public class FooTest { @Autowired Foo foo; @Test public void undeclaredCheckedExceotionIsThrown() { try { foo.foo(); Assert.fail(); } catch (RuntimeException e) { //that's what we expect to happen } } } /* application-context.xml */ <?xml version="1.0" encoding="UTF-8"?> <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" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schem...ng-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"> <aop:aspectj-autoproxy /> <bean id="foo" class="FooImpl" /> <bean id="fooAspect" class="FooAspect" /> </beans>
Maven project with code attached.
Thanks In Advancebreast cancer treatment
chaga mushroom


Reply With Quote

