Hi,
During an attempt to make my web application serializable, I got stuck on AspectJPointcutAdvisor not being serializable by Java's ObjectInputStream:
My test app uses applicationContext.xml:Code:java.io.NotSerializableException: org.springframework.aop.aspectj.AspectJPointcutAdvisor at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156) ...
and a trivial implementation of the Counter interface, CounterImpl class, and SimpleAspect:Code:<bean name="counter" class="test.CounterImpl" scope="session" /> <aop:config> <aop:aspect ref="aspectBean"> <aop:pointcut id="pointcut" expression="execution(* test.Counter.count())" /> <aop:around pointcut-ref="pointcut" method="doAround" /> </aop:aspect> </aop:config> <bean id="aspectBean" class="test.SimpleAspect" />
Btw, there is no exception when running this without serializing it or without the aspect.Code:public interface Counter { public int count(); } public class CounterImpl implements Counter, Serializable { private static final long serialVersionUID = 6830705610651059597L; private int count; public int count() { return ++count; } } public class SimpleAspect implements Serializable { private static final long serialVersionUID = 8861294436225901893L; public Object doAround(ProceedingJoinPoint pjp) throws Throwable { System.out.println("around"); return pjp.proceed(); } }
Assuming this is not a bug, I wander: How do I combine Spring's AOP with Java's serialization?
My setup uses Spring 3.0.1.RELEASE-A and Tomcat 6.0.24 with default configuration. The remainder of the web application is about as basic as it gets.
Thanks,
Leo


Reply With Quote
