ehcache / ehcache3

Ehcache 3.x line

Home Page:http://www.ehcache.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

sergmain opened this issue · comments

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

Thanks, we will have a look.