-
Nov 6th, 2007, 07:33 PM
#1
question about AOP
I'm learning AOP from <Pro Spring>.I type a example in MyEclipse.
package org.wlw.ASpringAOPTest;
/**
* @author wang
*
*/
public class MessageWriter {
public void writerMessage(){
System.out.println("World ");
}
}
package org.wlw.ASpringAOPTest;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
public class MessageDecorator implements MethodInterceptor {
public Object invoke(MethodInvocation invocation) throws Throwable {
System.out.println("Hello ");
Object retVal = invocation.proceed();
System.out.println("! ");
return retVal;
}
}
/**
*
*/
package org.wlw.ASpringAOPTest;
import org.springframework.aop.framework.ProxyFactory;
/**
* @author wang
*
*/
public class HelloWorldAOPExample {
/**
* @param args
*/
public static void main(String[] args) {
MessageWriter target = new MessageWriter();
ProxyFactory pf = new ProxyFactory();
pf.addAdvice(new MessageDecorator());
pf.setTarget(target);
MessageWriter proxy = (MessageWriter) pf.getProxy();
target.writerMessage();
proxy.writerMessage();
}
}
I cann't get the right results.
the Exceptions are:
Exception in thread "main" org.springframework.aop.framework.AopConfigExcepti on: Couldn't generate CGLIB subclass of cla
ss [class org.wlw.ASpringAOPTest.MessageWriter]: Common causes of this problem include using a final class or a non-visi
ble class; nested exception is net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->
null
Caused by: net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
at net.sf.cglib.core.AbstractClassGenerator.create(Ab stractClassGenerator.java:237)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer. java:377)
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:2 85)
at org.springframework.aop.framework.Cglib2AopProxy.g etProxy(Cglib2AopProxy.java:196)
at org.springframework.aop.framework.Cglib2AopProxy.g etProxy(Cglib2AopProxy.java:143)
at org.springframework.aop.framework.ProxyFactory.get Proxy(ProxyFactory.java:97)
at org.wlw.ASpringAOPTest.HelloWorldAOPExample.main(H elloWorldAOPExample.java:25)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.sf.cglib.core.ReflectUtils.defineClass(Reflect Utils.java:384)
at net.sf.cglib.core.AbstractClassGenerator.create(Ab stractClassGenerator.java:219)
... 6 more
Caused by: java.lang.SecurityException: class "org.wlw.ASpringAOPTest.MessageWriter$$EnhancerByC GLIB$$ccdb0a8e"'s signer
information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(Unknown Source)
at java.lang.ClassLoader.preDefineClass(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
... 12 more
the spring version is 1.2.9,java version is 1.6.3
thanks.
Last edited by hellowangyi; Nov 6th, 2007 at 08:01 PM.
-
Nov 7th, 2007, 01:12 AM
#2
-
Nov 7th, 2007, 10:08 AM
#3
hellowangyi,
You want to make sure you upgrade to MyEclipse 6.0.1, there was an issue with 6.0 where we had shipped some of the Spring/Hibernate libs signed and it created the problem you see there. We fixed it with a hotfix a few days later and that got rolled into the 6.0.1 release.
Sorry about the trouble, but hopefully it should be easy enough to pop the upgrade in using the MyEclipse menu and clicking on "Add Features", the Quick Installer will scan for updates and let you know if it finds any and you can just select them and hit OK.
Riyad
MyEclipse Support
-
Nov 7th, 2007, 11:42 AM
#4
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules