How to add blaze to spring boot project
See original GitHub issueI tried to add blaze to my spring boot project. I want to use the blaze criteria module. However, I am always getting errors during application startup or initialization of the CriteriaBuilderConfiguration.
On the spring side I am using the following dependencies:
- spring boot: 2.6.7
- spring data: 2.6.7 (comes with spring boot)
- hibernate: 5.6.8.Final (comes with spring boot)
- Java: 11
- blaze: 1.6.6
I added the blaze dependencies as described on this page: https://persistence.blazebit.com/downloads.html
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-core-api</artifactId>
<version>${com.blazebit.blaze-persistence.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-core-impl</artifactId>
<version>${com.blazebit.blaze-persistence.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-jpa-criteria-api</artifactId>
<version>${com.blazebit.blaze-persistence.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-jpa-criteria-impl</artifactId>
<version>${com.blazebit.blaze-persistence.version}</version>
<scope>runtime</scope>
</dependency>
With this configuration I get the following exception on creating the CriteriaBuilderFactory (EntityManager is injected by spring):
CriteriaBuilderConfiguration config = Criteria.getDefault();
// optionally, perform dynamic configuration
CriteriaBuilderFactory cbf = config.createCriteriaBuilderFactory(entityManager.getEntityManagerFactory());
Exception:
java.lang.IllegalArgumentException: No EntityManagerFactoryIntegrator was found on the classpath! Please check if an integration for your JPA provider is visible on the classpath!
at com.blazebit.persistence.impl.CriteriaBuilderFactoryImpl.<init>(CriteriaBuilderFactoryImpl.java:82) ~[blaze-persistence-core-impl-1.6.6.jar:1.6.6]
at com.blazebit.persistence.impl.CriteriaBuilderConfigurationImpl.createCriteriaBuilderFactory(CriteriaBuilderConfigurationImpl.java:2018) ~[blaze-persistence-core-impl-1.6.6.jar:1.6.6]
I added the dependency to “blaze-persistence-integration-spring-data-2.1” but with the same result. Last I added the hibernate integration (tried 5 and 5.4):
<dependency>
<groupId>com.blazebit</groupId>
<artifactId>blaze-persistence-integration-hibernate-5</artifactId>
<version>${com.blazebit.blaze-persistence.version}</version>
<scope>runtime</scope>
</dependency>
After adding this dependency I the the following error on application startup:
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
com.blazebit.persistence.integration.hibernate.Hibernate5MetadataContributor.contribute(Hibernate5MetadataContributor.java:82)
The following method did not exist:
'void org.hibernate.boot.internal.MetadataBuildingContextRootImpl.<init>(org.hibernate.boot.spi.MetadataBuildingOptions, org.hibernate.boot.spi.ClassLoaderAccess, org.hibernate.boot.spi.InFlightMetadataCollector)'
The calling method's class, com.blazebit.persistence.integration.hibernate.Hibernate5MetadataContributor, was loaded from the following location:
jar:file:/C:/Users/IMECS_DEV_SBUK/.m2/repository/com/blazebit/blaze-persistence-integration-hibernate-5/1.6.6/blaze-persistence-integration-hibernate-5-1.6.6.jar!/com/blazebit/persistence/integration/hibernate/Hibernate5MetadataContributor.class
The called method's class, org.hibernate.boot.internal.MetadataBuildingContextRootImpl, is available from the following locations:
jar:file:/C:/Users/IMECS_DEV_SBUK/.m2/repository/org/hibernate/hibernate-core/5.6.8.Final/hibernate-core-5.6.8.Final.jar!/org/hibernate/boot/internal/MetadataBuildingContextRootImpl.class
The called method's class hierarchy was loaded from the following locations:
org.hibernate.boot.internal.MetadataBuildingContextRootImpl: file:/C:/Users/IMECS_DEV_SBUK/.m2/repository/org/hibernate/hibernate-core/5.6.8.Final/hibernate-core-5.6.8.Final.jar
Action:
Correct the classpath of your application so that it contains compatible versions of the classes com.blazebit.persistence.integration.hibernate.Hibernate5MetadataContributor and org.hibernate.boot.internal.MetadataBuildingContextRootImpl
How to add blaze and blaze criteria to my spring boot project?` Thanks in advance! 😃
Issue Analytics
- State:
- Created a year ago
- Comments:6 (1 by maintainers)
Top GitHub Comments
It seems it still uses javax. I got the follwoing exception:
java.lang.ClassNotFoundException: jakarta.persistence.PersistenceException
After adding the right integration everything works fine:
You can use artifacts suffixed with “-jakarta” if you want to use the jakarta API