Announcement Announcement Module
Collapse
No announcement yet.
AspectJPointcutAdvisor not Serializable Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AspectJPointcutAdvisor not Serializable

    Hi,

    During an attempt to make my web application serializable, I got stuck on AspectJPointcutAdvisor not being serializable by Java's ObjectInputStream:
    Code:
    java.io.NotSerializableException: org.springframework.aop.aspectj.AspectJPointcutAdvisor
    	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
    	...
    My test app uses applicationContext.xml:
    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" />
    and a trivial implementation of the Counter interface, CounterImpl class, and SimpleAspect:
    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();
    	}
    }
    Btw, there is no exception when running this without serializing it or without the aspect.

    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

  • #2
    Hi!

    I have the same scenario and I couldn't solve this problem yet. I found a similar issue on Spring Jira (https://jira.springsource.org/browse/SPR-6910) but it seems there is not a estimated version to fix this issue. Does anybody have a workaround to solve this issue?

    Thanks

    Gleber

    Comment

    Working...
    X