Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring AOP proxies with annotation-based pointcuts are not serializable [SPR-6910] #11575

Closed
spring-projects-issues opened this issue Feb 25, 2010 · 6 comments
Assignees
Labels
has: votes-jira in: core type: enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Feb 25, 2010

Mauricio Noda opened SPR-6910 and commented

If a Spring bean is intercepted with an proxy based aspect using annotations on the pointcut expression, when Spring Web Flow tries to serialize the flow scope, the following exception is thrown:

org.springframework.webflow.execution.repository.snapshot.SnapshotCreationException: Could not serialize flow execution; make sure all objects stored in flow or flash scope are serializable
at org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshot.<init>(SerializedFlowExecutionSnapshot.java:74)
at org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshotFactory.createSnapshot(SerializedFlowExecutionSnapshotFactory.java:70)
at org.springframework.webflow.execution.repository.snapshot.AbstractSnapshottingFlowExecutionRepository.snapshot(AbstractSnapshottingFlowExecutionRepository.java:75)
at org.springframework.webflow.execution.repository.impl.DefaultFlowExecutionRepository.putFlowExecution(DefaultFlowExecutionRepository.java:123)
at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:165)
Truncated. see log file for complete stacktrace
java.io.NotSerializableException: org.springframework.aop.aspectj.annotation.InstantiationModelAwarePointcutAdvisorImpl
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1338)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1146)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
Truncated. see log file for complete stacktrace


Affects: 3.0 GA

Referenced from: commits 4adb7e2

12 votes, 12 watchers

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Feb 25, 2010

Mauricio Noda commented

This issue appears to affect Spring 3.0.1 too.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Feb 2, 2012

Pranav Sharma commented

Having the same issue and since SWF does not put enough info in the stacktrace, extremely tricky to find.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Apr 26, 2012

Pawel Jakubczyk commented

Also present in app using Spring v3.1.1.RELEASE and SWF v2.3.1.RELEASE.
Is there any known workaround for this issue (except for avoiding annotations in pointcut expressions)?

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented May 15, 2012

Chris Beams commented

No workaround available here; if any of the commenters/watchers here would like to take a shot at making InstantiationModelAwarePointcutAdvisorImpl serializable, please do per the contributor guidelines.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Oct 31, 2015

Marc Garcia commented

I'm using Spring AOP 4.2.1-RELEASE and it's also affected.

I have made some little changes on the source code of some classes in this jar (and in the class org.aspectj.internal.lang.reflect.AjTypeImpl in aspectjrt-1.8.7.jar and in aspectjweaver-1.8.7.jar) and finally I can run my application.

Basically I set "implement Serializable" in the classes that my application uses and I substituted the attributes of type java.lang.reflect.Method with 3 attributes:

private final Class methodClass; private final String methodName; private final Class[] methodParametersTypes

and its uses with:
this.methodClass.getDeclaredMethod(this.methodName, this.methodParametersTypes);

I think all these changes must be made in all classes of the package org.springframework.aop.aspectj. I have only modified the classes I need:

org.springframework.aop.aspectj.AbstractAspectJAdvice
org.springframework.aop.aspectj.AspectJAfterThrowingAdvice
org.springframework.aop.aspectj.AspectJAroundAdvice.java

org.springframework.aop.aspectj.annotation.AspectMetadata
org.springframework.aop.aspectj.annotation.BeanFactoryAspectInstanceFactory
org.springframework.aop.aspectj.annotation.InstantiationModelAwarePointcutAdvisorImpl
org.springframework.aop.aspectj.annotation.LazySingletonAspectInstanceFactoryDecorator
org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory

I have never used Github nor made a contribution to Spring, so if you want quickly my source code I can post here.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Dec 22, 2015

Juergen Hoeller commented

This seems to be achievable without modifying AjTypeImpl through re-resolution in readObject methods; I've applied the same recipe for Method re-resolution.

I'll do some further testing and will then commit this to master for inclusion in 4.3.

Juergen

@spring-projects-issues spring-projects-issues added type: enhancement in: core has: votes-jira labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.3 RC1 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has: votes-jira in: core type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants