spring icon indicating copy to clipboard operation
spring copied to clipboard

ClassCastException when using @EnableAsync in Spring

Open denis-anisimov opened this issue 6 years ago • 1 comments

@heruan commented on Fri Apr 06 2018

With Spring, if using @EnableAsync I'm starting getting cast exceptions e.g.

java.lang.ClassCastException: com.sun.proxy.$Proxy319 cannot be cast to
com.vaadin.flow.component.Component

but if I set @EnableAsync(proxyTargetClass = true) then all is working again.

I don't know what happens exactly here, but from the annotation docs I understand that the annotation changes the way all proxy are created—not just @Async annotated ones.

Don't know if this is something that should be fixed in Flow or just documented.

denis-anisimov avatar Apr 18 '18 07:04 denis-anisimov

I also had this issue but it resolved when I removed the @EnableGlobalMethodSecurity(securedEnabled = true) annotation I was using. As soon as I add the flag proxyTargetClass = true it works again. The view that caused the issue had a @Secured annotation and configuration similar to the bakery example.

I'm not yet sure if this is the real solution and if the Secured annotation for any REST interfaces besides the Vaadin application is still working but a hint in the direction where the problem is located.

psistorm avatar Nov 09 '18 10:11 psistorm