Reputation: 1324
Spring Data's @DomainEvents
with AbstractAggregateRoot
work great but fails for repository.save(Iterable<S> entities)
on the domain object it is used on.
The error trace is as below :-
java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:216)
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:201)
at org.springframework.data.repository.core.support.EventPublishingRepositoryProxyPostProcessor$EventPublishingMethod.publishEventsFrom(EventPublishingRepositoryProxyPostProcessor.java:173)
at org.springframework.data.repository.core.support.EventPublishingRepositoryProxyPostProcessor$EventPublishingMethodInterceptor.invoke(EventPublishingRepositoryProxyPostProcessor.java:97)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57)
at org.springframework.aop.framework.
The issue is cause the clearDomainEvents(…)
is being applied in the above case as per the code below in EventPublishingRepositoryProxyPostProcessor
if (clearingMethod != null) {
ReflectionUtils.invokeMethod(clearingMethod, object);
}
Will be great if this can be resolved or am I missing something here.
Upvotes: 1
Views: 1153
Reputation: 83131
You seem to be running into DATACMNS-1067, which has been fixed with the Ingalls SR4 release train. Please make sure to upgrade to this or (recommended) to the latest version, currently Ingalls SR7.
Upvotes: 2