quarkusio/quarkus · error · PersistenceException
This PersistenceProvider does not support createEntityManage
Error message
This PersistenceProvider does not support createEntityManagerFactory(PersistenceConfiguration). Quarkus is responsible for creating the entity manager factory, so inject your entity manager factory through CDI instead: `@Inject EntityManagerFactory emf`.
What it means
Quarkus replaces the standard JPA bootstrap with FastBootHibernatePersistenceProvider, which only supports creation from a PersistenceUnitInfo. The Jakarta Persistence programmatic PersistenceConfiguration overload is unsupported because Quarkus owns entity manager factory creation, so this method always throws PersistenceException pointing to CDI injection.
Source
Thrown at extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/FastBootHibernatePersistenceProvider.java:107
if (builder == null) {
log.trace("Could not obtain matching EntityManagerFactoryBuilder, returning null");
return null;
} else {
return builder.build();
}
}
@SuppressWarnings("rawtypes")
@Override
public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info, Map properties) {
log.tracef("Starting createContainerEntityManagerFactory : %s", info.getPersistenceUnitName());
return getEntityManagerFactoryBuilder(info, properties).build();
}
@Override
public EntityManagerFactory createEntityManagerFactory(PersistenceConfiguration configuration) {
throw new PersistenceException(
"This PersistenceProvider does not support createEntityManagerFactory(PersistenceConfiguration). "
+ " Quarkus is responsible for creating the entity manager factory, so inject your entity manager"
+ " factory through CDI instead: `@Inject EntityManagerFactory emf`.");
}
@SuppressWarnings("rawtypes")
@Override
public void generateSchema(PersistenceUnitInfo info, Map map) {
log.tracef("Starting generateSchema : PUI.name=%s", info.getPersistenceUnitName());
final EntityManagerFactoryBuilder builder = getEntityManagerFactoryBuilder(info, map);
builder.generateSchema();
}
@SuppressWarnings("rawtypes")
@Override
public boolean generateSchema(String persistenceUnitName, Map map) {
log.tracef("Starting generateSchema for persistenceUnitName %s", persistenceUnitName);View on GitHub (pinned to e1c734241f)
Solutions
- Inject the factory via CDI: @Inject EntityManagerFactory emf, or @Inject EntityManager em / Session session directly.
- Configure the persistence unit through application.properties (quarkus.hibernate-orm.*) instead of PersistenceConfiguration.
- For multiple PUs, use qualified injection (@PersistenceUnit("name") / @Inject @PersistenceUnitName("name")).
- Run plain-JPA integration tests outside the Quarkus runtime provider.
Example fix
// before
EntityManagerFactory emf = Persistence.createEntityManagerFactory(
new PersistenceConfiguration("mypu").property(...));
// after
@Inject
EntityManagerFactory emf; // or @Inject EntityManager em; Defensive patterns
Strategy: type-guard
Validate before calling
EntityManagerFactory emf;
try {
emf = CDI.current().select(EntityManagerFactory.class).get();
} catch (NoSuchEJBException | IllegalStateException e) {
throw new IllegalStateException("EMF not available via CDI; do not use Persistence.createEntityManagerFactory(PersistenceConfiguration) in Quarkus");
} Type guard
boolean isQuarkusRuntime() {
return Thread.currentThread().getContextClassLoader()
.getResource("io/quarkus/hibernate/orm/runtime/FastBootHibernatePersistenceProvider.class") != null;
} Try / catch
try {
Persistence.createEntityManagerFactory(config);
} catch (PersistenceException e) {
if (e.getMessage().contains("does not support createEntityManagerFactory")) {
emf = CDI.current().select(EntityManagerFactory.class).get();
} else throw e;
} Prevention
- Never call Persistence.createEntityManagerFactory(PersistenceConfiguration) inside Quarkus.
- Inject EMF/EM via CDI annotations instead of programmatic bootstrap.
- Configure PUs through quarkus.hibernate-orm.* properties.
When it happens
Trigger: Calling Persistence.createEntityManagerFactory(PersistenceConfiguration) in a Quarkus application; the provider resolves to FastBootHibernatePersistenceProvider and throws immediately.
Common situations: Porting plain Jakarta Persistence bootstrap code to Quarkus; tests building an EMF programmatically; following non-Quarkus documentation; migrating code that used a configuration builder for the EMF.
Related errors
- Unable to find an EntityManagerFactory for persistence unit
- Persistence unit is closed
- Multiple instances of %1$s were found for persistence unit %
- Persistence providers are not available during the static in
- Not supported for transaction scoped entity managers
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/58a66527b6e7cb34.
Report an issue: GitHub.