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 EntityManager proxy is incompatible with Hibernate Search <5.11.6 (FullTextEntityManager instantiation fails with ClassCastException) #26090
Comments
Thanks for the sample. I believe this change in behaviour is due to this change in Spring Framework 5.3. The
The We'll transfer this to the Spring Framework team so that they can take a look. |
@wilkinsona thanks for you detailed analysis! |
This is arguably a mismatch in Hibernate Search where it calls That said, I do see the point that previous |
We're exposing |
@jhoeller I've updated my example to use the latest 5.3.2-SNAPSHOT from master. Now the exception changes to the following:
Coming from the other cast inside hibernate search. Edit: Changing the |
Argh, another unguarded cast there! Thanks for the quick turnaround, in any case! I'll try the other approach right away, will ping you once it's ready in a shapshot. |
This is a quite subtle issue. Our differentiated handling of Frankly, Hibernate Search should call I'll keep trying further what we can do about it from our end. Ideally we'd also remain compatible with older Hibernate Search versions, even if this gets refined in the Search implementation. |
I'll try to replace the casts with calls to One important detail: can you confirm that calling |
Hey @yrodiere, thanks for chiming in! Indeed, |
@jhoeller Thanks for confirming this. For the record, here are the relevant PRs in Hibernate Search:
I'll try to release 5.11 early next week. |
Great news, @yrodiere - I'll leave our unwrap handling as-is then, updating our 5.3 migration notes accordingly. |
FYI I had experienced this issue and just updated to Hibernate Search 5.11.6. Happy to report that Spring and Hibernate Search are once again happy with each other. Thanks to all who worked on identifying and fixing the issue! |
I can confirm it as well - my application is running with Hibernate Search 5.11.6 and Spring Boot 2.4.0 without any issues. Thanks for your help! |
@knoobie I copy your code in github link and still has exception java.lang.ClassCastException: class jdk.proxy4.$Proxy100 cannot be cast to class org.hibernate.engine.spi.SessionImplementor (jdk.proxy4.$Proxy100 is in module jdk.proxy4 of loader org.springframework.boot.devtools.restart.classloader.RestartClassLoader @3ed2eee9; org.hibernate.engine.spi.SessionImplementor is in unnamed module of loader 'app') |
@Toan1606 if you update your dependencies, the problem is gone. Never had any problems since this was fixed. All Spring Framework / Boot and Hibernate Search versions afterwards work perfectly fine. |
I am testing it in spring boot version 2.7.1 |
Please check the |
My project is fixed in Hibernate Search 5 |
Is the code in your github link sure it was running before? |
After upgrading from 2.3.5.RELEASE to 2.4.0 instantiating a
FullTextEntityManager
(hibernate search) from an injectedEntityManager
is not possible anymore. The same code worked in the past and is derived from the official documentation or baeldung.Code to reproduce:
https://github.com/knoobie/spring-2-4-entitymanager
How to check:
Stacktrace:
The text was updated successfully, but these errors were encountered: