I am implementing a program in Spring-Boot using ObjectDB. To actually use ObjectDB I have followed this approach https://www.objectdb.com/forum/2523 which is working perfectly.
However, as soon as I want to use Spring-Actuator then I am getting the following errors:
Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.metrics.orm.jpa.HibernateMetricsAutoConfiguration': Injection of autowired dependencies failed; nested exception is com.objectdb.o.UserException: Unsupported unwrap(org.hibernate.SessionFactory.class) for EntityManagerFactory
Any ideas on how to solve this error?
I am using the exact same code as in the link. I have added Spring-Actuator in the pom like this:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
The failure is occurring because Spring Boot is trying to unwrap the JPA
EntityManagerFactoryto get Hibernate'sSessionFactory. It's attempting to do this as you have Hibernate on the classpath (it's a dependency ofspring-boot-starter-data-jpa). According to the JPA specification,unwrapshould throw aPersistenceException"if the provider does not support the call". Spring Boot catchesPersistenceExceptionin caseunwrapisn't supported. Unfortunately, ObjectDB is throwingcom.objectdb.o.UserExceptionwhich isn't spec compliant. I'd recommend raising this as an ObjectDB bug.You can avoid the problem by excluding Hibernate from the classpath. This will stop Spring Boot from attempting to unwrap Hibernate's
SessionFactory, preventing the ObjectDB bug from occurring. You can do so by adding an exclusion to thespring-boot-starter-data-jpadependency in yourpom.xml: