Commits
Tarun Sukhani authored 890aa923249
fix: probe for javax.persistence before HibernateMetrics bind (PF-87)
PF-86's reflection-based HibernateMetrics binding sidestepped the javac
overload-resolution check but tripped over the JVM's separate class-load
verification step: io.micrometer.core.instrument.binder.jpa.HibernateMetrics
declares `throws javax.persistence.PersistenceException` on its legacy
overload, so loading the class fails with NoClassDefFoundError on this
jakarta-only classpath before getMethod() even runs. The catch block
swallowed the exception, but every JVM startup logged a WARN with a
stacktrace and the Hibernate-metrics feature silently no-shipped.
Probe Class.forName("javax.persistence.EntityManagerFactory") at the
top of bindHibernateMetrics. If absent — the expected state on this
fork — log INFO once per data source explaining why the metrics aren't
binding, and return cleanly. Operators wanting Hibernate metrics can
opt in by adding javax.persistence-api to their app's dependencies.yml.
HikariCP, Caffeine, and JCache L2 bindings are unaffected (each is in
its own try/catch with its own classpath assumptions).
Reflection sidesteps javac. It does not sidestep the linker.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>