question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to add blaze to spring boot project

See original GitHub issue

I 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:closed
  • Created a year ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
IMECS1commented, Jul 18, 2022

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:

	  <dependency>
	      <groupId>com.blazebit</groupId>
	      <artifactId>blaze-persistence-integration-hibernate-5.6</artifactId>
	      <version>1.6.6</version>
	  </dependency>` 
0reactions
beikovcommented, Jul 23, 2022

You can use artifacts suffixed with “-jakarta” if you want to use the jakarta API

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Started with Blaze Persistence - Baeldung
To include Blaze Persistence core in our project, we'll need to add the following three dependencies in the pom.xml file:
Read more >
Issues - GitHub
Hi, I just tried 1.6.1 together with SB 2.5.4 and got several issues regarding java.time module not added in the entityViewObjectMapper and ...
Read more >
Entity View Module - Blaze Persistence
To use the Quarkus extension you need to add the following Maven dependency to your Quarkus project: <dependency> <groupId>com.blazebit</groupId> ...
Read more >
Create better Criteria queries with Blaze persistence
The Blaze Persistence project provides an interesting alternative to JPA's Criteria API. Both APIs enable you to define queries dynamically at runtime.
Read more >
Spring Boot - Thymeleaf with Example - GeeksforGeeks
Project Setup · Spring Web (Build web, including RESTful, applications using Spring MVC. · Spring Data JPA (Persist data in SQL stores with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found