<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>Spring Community Forums - AOP</title>
		<link>http://forum.springsource.org/</link>
		<description>Discussion on aspect-oriented programming with AspectJ and Spring AOP.</description>
		<language>en</language>
		<lastBuildDate>Tue, 21 May 2013 12:45:37 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://forum.springsource.org/images/misc/rss.png</url>
			<title>Spring Community Forums - AOP</title>
			<link>http://forum.springsource.org/</link>
		</image>
		<item>
			<title>Strange issue with AOP and autowired classes</title>
			<link>http://forum.springsource.org/showthread.php?137357-Strange-issue-with-AOP-and-autowired-classes&amp;goto=newpost</link>
			<pubDate>Mon, 13 May 2013 15:44:06 GMT</pubDate>
			<description><![CDATA[I am looking at a application where I see the below issues 
- I am trying to add a simple interceptor as mentioned on Spring website <a...]]></description>
			<content:encoded><![CDATA[<div>I am looking at a application where I see the below issues<br />
- I am trying to add a simple interceptor as mentioned on Spring website <a href="http://static.springsource.org/spring/docs/2.0.x/reference/transaction.html">http://static.springsource.org/sprin...ansaction.html</a><br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">&lt;!-- this is the aspect --&gt;<br />
&nbsp; &nbsp; &lt;bean id=&quot;profiler&quot; class=&quot;x.y.SimpleProfiler&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- execute before the transactional advice (hence the lower order number) --&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;property name=&quot;order&quot; value=&quot;1&quot;/&gt;<br />
&nbsp; &nbsp; &lt;/bean&gt;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &lt;tx:annotation-driven transaction-manager=&quot;txManager&quot; order=&quot;200&quot;/&gt;<br />
<br />
&nbsp; &nbsp; &lt;aop:config&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- this advice will execute around the transactional advice --&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;aop:aspect id=&quot;profilingAspect&quot; ref=&quot;profiler&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;aop:pointcut id=&quot;serviceMethodWithReturnValue&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; expression=&quot;execution(!void x.y..*Service.*(..))&quot;/&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;aop:around method=&quot;profile&quot; pointcut-ref=&quot;serviceMethodWithReturnValue&quot;/&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/aop:aspect&gt;<br />
&nbsp; &nbsp; &lt;/aop:config&gt;</code><hr />
</div>In the service, I am trying to add advice(XYZService) to, there is a dependency which has @Autowired annotation<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">&nbsp; @Autowired<br />
&nbsp; &nbsp; private ABFactory abFactory;</code><hr />
</div>The above mentioned ABFactory is a class and not a interface.( This is existing code and I am not sure why the autowiring has been done to class and not interface).<br />
<br />
Issue:<br />
-----------<br />
When i try running test class, get following error<br />
Caused by: org.springframework.aop.framework.AopConfigExcepti  on: Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.<br />
<br />
I do not want to add CGLIb proxies as it is better to use JDK dynamic proxies. <br />
<br />
If I remove the custom interceptor and leave the &quot;&lt;tx:annotation-driven transaction-manager..&quot; advice it works. Why is the issue with CGLib proxies only happening when I try the &lt;aop:config&gt; for custom advice. Should the behavior not be same for the transaction advice as well?</div>

]]></content:encoded>
			<category domain="http://forum.springsource.org/forumdisplay.php?31-AOP">AOP</category>
			<dc:creator>deepannair</dc:creator>
			<guid isPermaLink="true">http://forum.springsource.org/showthread.php?137357-Strange-issue-with-AOP-and-autowired-classes</guid>
		</item>
		<item>
			<title>Spring+AspectJ AOP config with JSP</title>
			<link>http://forum.springsource.org/showthread.php?137120-Spring-AspectJ-AOP-config-with-JSP&amp;goto=newpost</link>
			<pubDate>Tue, 07 May 2013 08:09:21 GMT</pubDate>
			<description>I have configured AspectJ in my spring application. Since my app is a legacy app which is using JSP scriptlet code for server side processing. 
  
...</description>
			<content:encoded><![CDATA[<div>I have configured AspectJ in my spring application. Since my app is a legacy app which is using JSP scriptlet code for server side processing.<br />
 <br />
 The problem I am facing is that I want to invoke an @AfterThrowing Advice when an Exception occurs in the JSP scriptlet code. <br />
 <br />
 My Advice method signature as of now is:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">@Aspect**public*class*NotificationAdvice*{********<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @AfterThrowing(pointcut*=*&quot;execution(**com.app.OtherBeanIntf.doSomething(..))&quot;,*throwing*=*&quot;error&quot;)******<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  public*void*logAfterThrowing(JoinPoint*joinPoint,*Throwable*error)*{*</code><hr />
</div>In the above code, OtherBeanIntf is another Java bean which is working fine with this logging advice. Now how do I configure this advice to work with JSP scriptlet code too?</div>

]]></content:encoded>
			<category domain="http://forum.springsource.org/forumdisplay.php?31-AOP">AOP</category>
			<dc:creator>extremejava</dc:creator>
			<guid isPermaLink="true">http://forum.springsource.org/showthread.php?137120-Spring-AspectJ-AOP-config-with-JSP</guid>
		</item>
		<item>
			<title><![CDATA[Mistake of "Type mismatch"]]></title>
			<link>http://forum.springsource.org/showthread.php?137116-Mistake-of-quot-Type-mismatch-quot&amp;goto=newpost</link>
			<pubDate>Tue, 07 May 2013 07:30:18 GMT</pubDate>
			<description>I want to exercise AOP,so I use follwing example code: 
 
 
Code: 
--------- 
package com.apress.prospring3.ch6.staticpc; 
import...</description>
			<content:encoded><![CDATA[<div>I want to exercise AOP,so I use follwing example code:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">package com.apress.prospring3.ch6.staticpc;<br />
import java.lang.reflect.Method;<br />
import net.sf.cglib.proxy.MethodInterceptor;<br />
import net.sf.cglib.proxy.MethodProxy;<br />
import org.aopalliance.intercept.MethodInvocation;<br />
public class SimpleAdvice implements MethodInterceptor {<br />
&nbsp; &nbsp; &nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; &nbsp; &nbsp; public Object intercept(Object arg0, Method arg1, Object[] arg2,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MethodProxy arg3) throws Throwable {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // TODO Auto-generated method stub<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return null;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; public Object invoke(MethodInvocation invocation) throws Throwable{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(&quot;&gt;&gt; Invoking &quot;+invocation.getMethod().getName());<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Object retVal=invocation.proceed();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(&quot;&gt;&gt; Done&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return retVal;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</code><hr />
</div><div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">package com.apress.prospring3.ch6.staticpc;<br />
import org.aopalliance.aop.Advice;<br />
import org.springframework.aop.Advisor;<br />
import org.springframework.aop.Pointcut;<br />
import org.springframework.aop.support.DefaultPointcutAdvisor;<br />
public class StaticPointcutExample {<br />
&nbsp; &nbsp; &nbsp; &nbsp; public static void main(String[] args){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BeanOne one=new BeanOne();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BeanTwo two=new BeanTwo();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BeanOne proxyOne;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BeanTwo proxyTwo;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Pointcut pc=new SimpleStaticPointcut();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Advice advice=new SimpleAdvice();&nbsp; //compile error here<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</code><hr />
</div>When I run StaticPointcutExample ,it raise following error:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">Type mismatch: cannot convert from SimpleAdvice to Advice</code><hr />
</div>Where is wrong? How to correct it? <br />
Thanks</div>

]]></content:encoded>
			<category domain="http://forum.springsource.org/forumdisplay.php?31-AOP">AOP</category>
			<dc:creator>EdwardKing</dc:creator>
			<guid isPermaLink="true">http://forum.springsource.org/showthread.php?137116-Mistake-of-quot-Type-mismatch-quot</guid>
		</item>
		<item>
			<title>Problem whe implementing interface</title>
			<link>http://forum.springsource.org/showthread.php?137076-Problem-whe-implementing-interface&amp;goto=newpost</link>
			<pubDate>Mon, 06 May 2013 13:33:44 GMT</pubDate>
			<description>Hello, 
 
I have a class MyClass implementing an interface MyInterface and I would like to execute some code injected by AOP each time a method of...</description>
			<content:encoded><![CDATA[<div>Hello,<br />
<br />
I have a class MyClass implementing an interface MyInterface and I would like to execute some code injected by AOP each time a method of MyClass is invoked. My AOP class implementation is AOPImpl.<br />
To test all of this, I coded a junit test.<br />
<br />
The issue is that the test fails with the following exception<br />
<br />
SEVERE: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.Dependenc  yInjectionTestExecutionListener@2a462a46] to prepare test instance [com.aop.test.TestAOP@60b460b4]<br />
Throwable occurred: org.springframework.beans.factory.BeanCreationExce  ption: Error creating bean with name 'com.aop.test.TestAOP': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationExce  ption: Could not autowire field: private com.aop.test.MyClass com.aop.test.TestAOP.dao; nested exception is org.springframework.beans.factory.NoSuchBeanDefini  tionException: No matching bean of type [com.aop.test.MyClass] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Aut  owired(required=true)}<br />
	at org.springframework.beans.factory.annotation.Autow  iredAnnotationBeanPostProcessor.postProcessPropert  yValues(AutowiredAnnotationBeanPostProcessor.java:  287)<br />
	at org.springframework.beans.factory.support.Abstract  AutowireCapableBeanFactory.populateBean(AbstractAu  towireCapableBeanFactory.java:1106)<br />
	at org.springframework.beans.factory.support.Abstract  AutowireCapableBeanFactory.autowireBeanProperties(  AbstractAutowireCapableBeanFactory.java:374)<br />
	at org.springframework.test.context.support.Dependenc  yInjectionTestExecutionListener.injectDependencies  (DependencyInjectionTestExecutionListener.java:110  )<br />
	at org.springframework.test.context.support.Dependenc  yInjectionTestExecutionListener.prepareTestInstanc  e(DependencyInjectionTestExecutionListener.java:75  )<br />
	at org.springframework.test.context.TestContextManage  r.prepareTestInstance(TestContextManager.java:321)<br />
	at org.springframework.test.context.junit4.SpringJUni  t4ClassRunner.createTest(SpringJUnit4ClassRunner.j  ava:211)<br />
	at org.springframework.test.context.junit4.SpringJUni  t4ClassRunner$1.runReflectiveCall(SpringJUnit4Clas  sRunner.java:288)<br />
	at org.junit.internal.runners.model.ReflectiveCallabl  e.run(ReflectiveCallable.java:15)<br />
	at org.springframework.test.context.junit4.SpringJUni  t4ClassRunner.methodBlock(SpringJUnit4ClassRunner.  java:290)<br />
	at org.springframework.test.context.junit4.SpringJUni  t4ClassRunner.runChild(SpringJUnit4ClassRunner.jav  a:231)<br />
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(  BlockJUnit4ClassRunner.java:47)<br />
	at org.junit.runners.ParentRunner$3.run(ParentRunner.  java:231)<br />
	at org.junit.runners.ParentRunner$1.schedule(ParentRu  nner.java:60)<br />
	at org.junit.runners.ParentRunner.runChildren(ParentR  unner.java:229)<br />
	at org.junit.runners.ParentRunner.access$000(ParentRu  nner.java:50)<br />
	at org.junit.runners.ParentRunner$2.evaluate(ParentRu  nner.java:222)<br />
	at org.springframework.test.context.junit4.statements  .RunBeforeTestClassCallbacks.evaluate(RunBeforeTes  tClassCallbacks.java:61)<br />
	at org.springframework.test.context.junit4.statements  .RunAfterTestClassCallbacks.evaluate(RunAfterTestC  lassCallbacks.java:71)<br />
	at org.junit.runners.ParentRunner.run(ParentRunner.ja  va:300)<br />
	at org.springframework.test.context.junit4.SpringJUni  t4ClassRunner.run(SpringJUnit4ClassRunner.java:174  )<br />
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestR  eference.run(JUnit4TestReference.java:50)<br />
	at org.eclipse.jdt.internal.junit.runner.TestExecutio  n.run(TestExecution.java:38)<br />
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRu  nner.runTests(RemoteTestRunner.java:467)<br />
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRu  nner.runTests(RemoteTestRunner.java:683)<br />
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRu  nner.run(RemoteTestRunner.java:390)<br />
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRu  nner.main(RemoteTestRunner.java:197)<br />
Caused by: org.springframework.beans.factory.BeanCreationExce  ption: Could not autowire field: private com.aop.test.MyClass com.aop.test.TestAOP.dao; nested exception is org.springframework.beans.factory.NoSuchBeanDefini  tionException: No matching bean of type [com.aop.test.MyClass] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Aut  owired(required=true)}<br />
	at org.springframework.beans.factory.annotation.Autow  iredAnnotationBeanPostProcessor$AutowiredFieldElem  ent.inject(AutowiredAnnotationBeanPostProcessor.ja  va:506)<br />
	at org.springframework.beans.factory.annotation.Injec  tionMetadata.inject(InjectionMetadata.java:87)<br />
	at org.springframework.beans.factory.annotation.Autow  iredAnnotationBeanPostProcessor.postProcessPropert  yValues(AutowiredAnnotationBeanPostProcessor.java:  284)<br />
	... 26 more<br />
Caused by: org.springframework.beans.factory.NoSuchBeanDefini  tionException: No matching bean of type [com.aop.test.MyClass] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Aut  owired(required=true)}<br />
	at org.springframework.beans.factory.support.DefaultL  istableBeanFactory.raiseNoSuchBeanDefinitionExcept  ion(DefaultListableBeanFactory.java:924)<br />
	at org.springframework.beans.factory.support.DefaultL  istableBeanFactory.doResolveDependency(DefaultList  ableBeanFactory.java:793)<br />
	at org.springframework.beans.factory.support.DefaultL  istableBeanFactory.resolveDependency(DefaultListab  leBeanFactory.java:707)<br />
	at org.springframework.beans.factory.annotation.Autow  iredAnnotationBeanPostProcessor$AutowiredFieldElem  ent.inject(AutowiredAnnotationBeanPostProcessor.ja  va:478)<br />
	... 28 more<br />
<br />
<br />
If I remove the inheritance from MyClass, all works fine. Anyone can explain please where am I wrong?<br />
Thanks for any suggestion.<br />
<br />
<b>MyInterface</b><br />
public interface MyInterface {<br />
	public void waitAMoment(long ms) throws InterruptedException;<br />
}<br />
<br />
<b>MyClass</b><br />
public class MyClass implements MyInterface {<br />
<br />
	public void waitAMoment(long ms) throws InterruptedException {<br />
		Thread.sleep(ms);<br />
		System.out.println(&quot;Waited &quot; + ms + &quot; ms&quot;);<br />
	}<br />
}<br />
<b><br />
Test class</b><br />
@RunWith(SpringJUnit4ClassRunner.class)<br />
@ContextConfiguration(locations = { &quot;classpath:applicationContext.xml&quot; })<br />
public class TestAOP {<br />
	@Autowired<br />
	private MyClass dao;<br />
<br />
	@Test<br />
	public void test() throws InterruptedException {<br />
			dao.waitAMoment(10);<br />
	}<br />
}<br />
<br />
<b>Spring config applicationContext.xml</b><br />
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br />
&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;<br />
	xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:context=&quot;http://www.springframework.org/schema/context&quot;<br />
	xmlns:ws=&quot;http://jax-ws.dev.java.net/spring/core&quot; xmlns:aop=&quot;http://www.springframework.org/schema/aop&quot;<br />
	xsi:schemaLocation=&quot;<br />
		<a href="http://www.springframework.org/schema/beans">http://www.springframework.org/schema/beans</a> <a href="http://www.springframework.org/schema/beans/spring-beans.xsd">http://www.springframework.org/schem...ring-beans.xsd</a> <br />
		<a href="http://www.springframework.org/schema/context">http://www.springframework.org/schema/context</a> <a href="http://www.springframework.org/schema/context/spring-context.xsd">http://www.springframework.org/schem...ng-context.xsd</a><br />
		<a href="http://www.springframework.org/schema/aop">http://www.springframework.org/schema/aop</a> http://www.springframework.org/schema/aop/spring-aop-2.5.xsd&quot;&gt;<br />
<br />
	&lt;bean name=&quot;testDAO&quot; class=&quot;com.aop.test.MyClass&quot;/&gt;<br />
<br />
	&lt;bean id=&quot;logAspect&quot; class=&quot;com.aop.test.AOPImpl&quot; /&gt;<br />
<br />
	&lt;aop:config&gt;<br />
		&lt;aop:aspect id=&quot;aspectLoggging&quot; ref=&quot;logAspect&quot;&gt;<br />
			&lt;!-- @Around --&gt;<br />
			&lt;aop:pointcut id=&quot;pointCutAround&quot; expression=&quot;execution(* com.aop..*MyInterface+.*(..))&quot; /&gt;<br />
			&lt;aop:around method=&quot;logInvocationAndParameters&quot;<br />
				pointcut-ref=&quot;pointCutAround&quot; /&gt;<br />
		&lt;/aop:aspect&gt;<br />
	&lt;/aop:config&gt;<br />
&lt;/beans&gt;</div>

]]></content:encoded>
			<category domain="http://forum.springsource.org/forumdisplay.php?31-AOP">AOP</category>
			<dc:creator>giorgio_anastopoulos</dc:creator>
			<guid isPermaLink="true">http://forum.springsource.org/showthread.php?137076-Problem-whe-implementing-interface</guid>
		</item>
		<item>
			<title>compile error</title>
			<link>http://forum.springsource.org/showthread.php?137069-compile-error&amp;goto=newpost</link>
			<pubDate>Mon, 06 May 2013 09:08:52 GMT</pubDate>
			<description>I use Spring Tool Suite 3.1.0 to create a spring project,and I put following jar into classpath 
org.springframework.asm_3.1.1.RELEASE.jar...</description>
			<content:encoded><![CDATA[<div>I use Spring Tool Suite 3.1.0 to create a spring project,and I put following jar into classpath<br />
org.springframework.asm_3.1.1.RELEASE.jar<br />
org.springframework.beans_3.1.1.RELEASE.jar<br />
org.springframework.context.support_3.1.1.RELEASE.  jar<br />
org.springframework.context_3.1.1.RELEASE.jar<br />
org.springframework.core_3.1.1.RELEASE.jar<br />
org.springframework.aop_3.1.1.RELEASE.jar<br />
<br />
Then I write following two code:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">package com.apress.prospring3.ch7.cflow;<br />
import java.lang.reflect.Method;<br />
import org.springframework.aop.MethodBeforeAdvice;<br />
public class SimpleBeforeAdvice implements MethodBeforeAdvice{<br />
&nbsp;@Override <br />
&nbsp;public void before(Method method, Object[] arg1, Object arg2)<br />
&nbsp;  throws Throwable {<br />
&nbsp; // TODO Auto-generated method stub<br />
&nbsp; System.out.println(&quot;Before method: &quot;+method);<br />
&nbsp;}<br />
}</code><hr />
</div><div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">package com.apress.prospring3.ch7.cflow;<br />
import org.springframework.aop.Advisor;<br />
import org.springframework.aop.Pointcut;<br />
import org.springframework.aop.framework.ProxyFactory;<br />
import org.springframework.aop.support.ControlFlowPointcut;<br />
import org.springframework.aop.support.DefaultPointcutAdvisor;<br />
public class ControlFlowExample {<br />
&nbsp;public static void main(String[] args){<br />
&nbsp; ControlFlowExample ex=new ControlFlowExample();<br />
&nbsp; ex.run();&nbsp; <br />
&nbsp;}&nbsp;  <br />
&nbsp;public void run(){ <br />
&nbsp; TestBean target=new TestBean();<br />
&nbsp; Pointcut pc=new ControlFlowPointcut(ControlFlowExample.class,&quot;test&quot;);<br />
&nbsp; Advisor advisor=new DefaultPointcutAdvisor(pc,new SimpleBeforeAdvice());<br />
&nbsp; ProxyFactory pf=new ProxyFactory();<br />
&nbsp; pf.setTarget(target);<br />
&nbsp; pf.addAdvisor(advisor);<br />
&nbsp; TestBean proxy=(TestBean)pf.getProxy();<br />
&nbsp; System.out.println(&quot;Trying normal invoke&quot;);<br />
&nbsp; proxy.foo();<br />
&nbsp; System.out.println(&quot;Trying under ControlFlowExample.test()&quot;);<br />
&nbsp; test(proxy);<br />
&nbsp;}<br />
&nbsp;private void test(TestBean bean){<br />
&nbsp; bean.foo();<br />
&nbsp;}<br />
}</code><hr />
</div>Above two code can't compile,the error of SimpleBeforeAdvice is follows:<br />
Multiple markers at this line<br />
 - The hierarchy of the type SimpleBeforeAdvice is <br />
  inconsistent<br />
 - Breakpoint:SimpleBeforeAdvice<br />
<br />
the error of ControlFlowExample is follows:<br />
Multiple markers at this line<br />
 - Line breakpoint:ControlFlowExample [line: 17] - run()<br />
 - The constructor DefaultPointcutAdvisor(Pointcut, SimpleBeforeAdvice) is <br />
  undefined<br />
<br />
Why I can't compile above code? Missing jar file?  How to make above code to run?<br />
Thanks</div>

]]></content:encoded>
			<category domain="http://forum.springsource.org/forumdisplay.php?31-AOP">AOP</category>
			<dc:creator>EdwardKing</dc:creator>
			<guid isPermaLink="true">http://forum.springsource.org/showthread.php?137069-compile-error</guid>
		</item>
		<item>
			<title>ObjectMapper not being woven by load time weaver.</title>
			<link>http://forum.springsource.org/showthread.php?137016-ObjectMapper-not-being-woven-by-load-time-weaver&amp;goto=newpost</link>
			<pubDate>Fri, 03 May 2013 16:28:06 GMT</pubDate>
			<description><![CDATA[I am attempting to use aspectj load time weaving(<context:load-time-weaver />) alongside the <mvc:annotation-driven/> directive. 
 
My issue is that...]]></description>
			<content:encoded><![CDATA[<div>I am attempting to use aspectj load time weaving(&lt;context:load-time-weaver /&gt;) alongside the &lt;mvc:annotation-driven/&gt; directive.<br />
<br />
My issue is that the com.fasterxml.jackson.databind.ObjectMapper class is not be woven at load time.  After some digging, I realized that it was because the &lt;mvc:annotation-driven/&gt; directive loads the MappingJackson2HttpMessageConverter, which creates a new ObjectMapper instance.  This all happens before the org.springframework.context.weaving.AspectJWeaving  Enabler's postProcessBeanFactory method is called and the AspectJ weaver is enabled.  <br />
<br />
The end result of this is that the ObjectMapper is loaded by the TomcatInstrumentableClassLoader prior Spring switching on aspectj load time waving, and is therefore not woven.  <br />
<br />
I realize that I could use the following configuration in lieu of &lt;mvc:annotation-driven /&gt; <br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">&lt;bean name=&quot;objectMapper&quot; class=&quot;com.fasterxml.jackson.databind.ObjectMapper&quot;/&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;bean class=&quot;org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;property name=&quot;messageConverters&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;list&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;bean class=&quot;org.springframework.http.converter.json.MappingJackson2HttpMessageConverter&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;property name=&quot;objectMapper&quot; ref=&quot;objectMapper&quot; /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/bean&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ...... Other converters&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/list&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/property&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/bean&gt;</code><hr />
</div><br />
This solution is not ideal because the aspect code is in a shared jar used by 8 different spring projects within my organization.  I want to allow these projects, and any future projects using the shared jar to retain the ability to use the &lt;mvc:annotation-driven /&gt; directive without having to worry about the specifics of the shared jar.<br />
<br />
If anyone has suggestions as to how I can use both the &lt;context:load-time-weaver /&gt; directive and the  &lt;mvc:annotation-driven/&gt; directive in my spring configuration and have the ObjectMapper woven, I would be grateful.<br />
<br />
META-INF/aop.xml<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">&lt;!DOCTYPE aspectj PUBLIC &quot;-//AspectJ//DTD//EN&quot; &quot;http://www.eclipse.org/aspectj/dtd/aspectj.dtd&quot;&gt;<br />
&lt;aspectj&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;weaver options=&quot;&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;include within=&quot;com.collegenet.jackson.map.aspect.JsonFilterAspect&quot;/&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;include within=&quot;com.fasterxml.jackson.databind.ObjectMapper&quot; /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;include within=&quot;web.mvc..*&quot;/&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/weaver&gt;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;aspects&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;aspect name=&quot;com.collegenet.jackson.map.aspect.JsonFilterAspect&quot;/&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/aspects&gt;<br />
&lt;/aspectj&gt;</code><hr />
</div>web/META-INF/context.xml<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">&lt;Context reloadable=&quot;false&quot;&gt;<br />
&lt;Loader loaderClass=&quot;org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader&quot;/&gt;<br />
&lt;/Context&gt;</code><hr />
</div>Version Details<br />
Spring MVC - 3.1.2.RELEASE<br />
Spring Instument Tomcat - 3.1.2.RELEASE<br />
Spring AOP - 3.1.2.RELEASE<br />
AspectJ jars (aspectjweaver and aspectjrt) - 1.6.9<br />
Jackson - 2.1.2<br />
<br />
<br />
If there is any further information I can provide, please let me know and thank you for taking a look at this issue.</div>

]]></content:encoded>
			<category domain="http://forum.springsource.org/forumdisplay.php?31-AOP">AOP</category>
			<dc:creator>lucasmilne</dc:creator>
			<guid isPermaLink="true">http://forum.springsource.org/showthread.php?137016-ObjectMapper-not-being-woven-by-load-time-weaver</guid>
		</item>
		<item>
			<title><![CDATA[can AOP be applied in webapplicationcontext&#65311;]]></title>
			<link>http://forum.springsource.org/showthread.php?136805-can-AOP-be-applied-in-webapplicationcontext&#65311;&amp;goto=newpost</link>
			<pubDate>Sat, 27 Apr 2013 09:32:10 GMT</pubDate>
			<description><![CDATA[Suppose I built a web program with spring-web mvc and the servlet name is set "demo" with class DispatcherServlet in  "web.xml". In the...]]></description>
			<content:encoded><![CDATA[<div>Suppose I built a web program with spring-web mvc and the servlet name is set &quot;demo&quot; with class DispatcherServlet in  &quot;web.xml&quot;. In the &quot;demo-servlet.xml&quot; file there are configurations of the beans, including some controllers to handle requests (extend the MultiActionController).  <br />
<br />
If I want to enable AOP to a controller bean defined in the &quot;demo-servlet.xml&quot; file, how can I do it? I have tried the @aspectJ annotations like the way to enable AOP in applicationContent.xml, but it did not work.<br />
<br />
Thanks!</div>

]]></content:encoded>
			<category domain="http://forum.springsource.org/forumdisplay.php?31-AOP">AOP</category>
			<dc:creator>fifman</dc:creator>
			<guid isPermaLink="true"><![CDATA[http://forum.springsource.org/showthread.php?136805-can-AOP-be-applied-in-webapplicationcontext&#65311;]]></guid>
		</item>
		<item>
			<title>Spring 3.1, Aspects and Jetty</title>
			<link>http://forum.springsource.org/showthread.php?136548-Spring-3-1-Aspects-and-Jetty&amp;goto=newpost</link>
			<pubDate>Sun, 21 Apr 2013 16:28:14 GMT</pubDate>
			<description>I have an application that uses Aspects with Spring 3.1. *It runs perfectly with Tomcat 7*. The advised methods get called as expected. 
 
I want it...</description>
			<content:encoded><![CDATA[<div>I have an application that uses Aspects with Spring 3.1. <b>It runs perfectly with Tomcat 7</b>. The advised methods get called as expected.<br />
<br />
I want it to work with Jetty 6.19. I've previously used Aspects with Spring 2.0 and Jetty with no major problems apart from adding a JVM agent. However I've had no luck with Jetty 6.22 and my Spring 3.1 application. I start Jetty with the javaagent thus<br />
<br />
-javaagent:./spring-instrument-3.1.3.RELEASE.jar<br />
<br />
where the Spring Instrument jar is in my CWD.<br />
<br />
There is a similar question on StackOverFlow but no-one was able to come up with a working answer.</div>

]]></content:encoded>
			<category domain="http://forum.springsource.org/forumdisplay.php?31-AOP">AOP</category>
			<dc:creator>davidof</dc:creator>
			<guid isPermaLink="true">http://forum.springsource.org/showthread.php?136548-Spring-3-1-Aspects-and-Jetty</guid>
		</item>
	</channel>
</rss>
