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

Ehcache 3.x incorrectly working with uri classpath://ehcache.xml - org.xml.sax.SAXParseException: Content is not allowed in prolog. #3195

Open
sergmain opened this issue Aug 19, 2023 · 1 comment

Comments

@sergmain
Copy link

sergmain commented Aug 19, 2023

This bug is happened in following environment - Spring Boot 3 + Tomcat + hibernate + Ehcache

Cause:
In such configuration Tomcat override a list of URL handlers by registering itself as URLStreamHandlerFactory. as a result a new handler for protocol 'classpath' is adding to list of handlers in java.net.URL

As a result the following code in hibernate isn't generating MalformedURLException for classpath://ehcache.xml because 'classpath' now is a correct protocol
https://github.com/hibernate/hibernate-orm/blob/8461ba2078657caf58930b9485020fe89aff4afe/hibernate-core/src/main/java/org/hibernate/boot/registry/classloading/internal/ClassLoaderServiceImpl.java#L134

and as following result hibernate is calling ehcache with Url(classpath://ehcache.xml). In 'normal' situation Ehcache would be called with full path to file ehcache.xml

When Ehcache is starting processing Url(classpath://ehcache.xml) for unknown reason stream contains rubbish data instead of actual content of ehcache.xml

there is a simple project for reproducing a bug:

https://github.com/sergmain/ehcache-bug-3195

java.vendor.version: Temurin-17.0.7+7

@jhouserizer
Copy link
Member

Thanks, we will have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants