quarkusio/quarkus · error · ConfigurationException
Persistence unit '${quarkus.security-jpa.persistence-unit-na
Error message
Persistence unit '${quarkus.security-jpa.persistence-unit-name value}' specified with the 'quarkus.security-jpa.persistence-unit-name' configuration property does not exist. Please set valid persistence unit name. What it means
At build time the security-jpa extension validates that the persistence unit named by quarkus.security-jpa.persistence-unit-name exists among the Hibernate ORM persistence unit descriptors. If no descriptor matches, it throws ConfigurationException because the JPA identity store cannot be wired without a valid persistence unit.
Source
Thrown at extensions/security-jpa/deployment/src/main/java/io/quarkus/security/jpa/deployment/QuarkusSecurityJpaProcessor.java:275
}
}
private static void activateCDIRequestContext(ClassCreator cc) {
cc.method("requireActiveCDIRequestContext", mc -> {
mc.protected_();
mc.returning(boolean.class);
mc.body(bc -> {
bc.return_(true);
});
});
}
private static boolean shouldActivateCDIReqCtx(List<PersistenceUnitDescriptorBuildItem> puDescriptors,
SecurityJpaBuildTimeConfig secJpaConfig) {
var descriptor = puDescriptors.stream()
.filter(desc -> secJpaConfig.persistenceUnitName().equals(desc.getPersistenceUnitName())).findFirst();
if (descriptor.isEmpty()) {
throw new ConfigurationException("Persistence unit '" + secJpaConfig.persistenceUnitName()
+ "' specified with the 'quarkus.security-jpa.persistence-unit-name' configuration property"
+ " does not exist. Please set valid persistence unit name.");
}
// 'io.quarkus.hibernate.orm.runtime.tenant.TenantResolver' is only resolved when CDI request context is active
// we need to active request context even when TenantResolver is @ApplicationScoped for tenant to be set
// see io.quarkus.hibernate.orm.runtime.tenant.HibernateCurrentTenantIdentifierResolver.resolveCurrentTenantIdentifier
// for more information
return descriptor.get().getConfig().getMultiTenancyStrategy() != MultiTenancyStrategy.NONE;
}
static final class EnabledIfNonDefaultPersistenceUnit implements BooleanSupplier {
private final boolean useNonDefaultPersistenceUnit;
public EnabledIfNonDefaultPersistenceUnit(SecurityJpaBuildTimeConfig config) {
this.useNonDefaultPersistenceUnit = !DEFAULT_PERSISTENCE_UNIT_NAME.equals(config.persistenceUnitName());
}
View on GitHub (pinned to e1c734241f)
Solutions
- Set quarkus.security-jpa.persistence-unit-name to the exact name of an existing persistence unit (check quarkus.hibernate.orm.persistence-unit.<name> config or the default unnamed PU).
- Remove the property to use the default persistence unit if only one exists.
- Define the missing persistence unit in quarkus.hibernate.orm.persistence-unit.<name>.* properties.
- Verify the hibernate-orm extension and datasource are properly configured.
Example fix
# before quarkus.security-jpa.persistence-unit-name=userPU # no such PU # after quarkus.security-jpa.persistence-unit-name=users quarkus.hibernate.orm.persistence-unit.users.datasource=users-ds
Defensive patterns
Strategy: validation
Validate before calling
String puName = config.securityJpaPersistenceUnitName();
boolean exists = puName == null || allConfiguredPersistenceUnits().contains(puName);
if (!exists) throw new IllegalStateException("Unknown PU: " + puName); Try / catch
try { quarkusBuild(); } catch (ConfigurationException e) { /* fix quarkus.security-jpa.persistence-unit-name */ } Prevention
- Copy the PU name exactly from quarkus.hibernate.orm.persistence-unit.<name> config
- Remove the property to use the default PU when only one exists
- Ensure the hibernate-orm extension is present so PUs are registered
When it happens
Trigger: Setting quarkus.security-jpa.persistence-unit-name to a name that does not match any persistence unit defined in the application (or configuring a custom name while no persistence units are defined).
Common situations: Typo in the persistence unit name; renaming a persistence unit in hibernate config without updating security-jpa config; multiple datasources where the security PU was removed; forgetting the hibernate-orm dependency so no PUs are registered.
Related errors
- Unable to find an EntityManagerFactory for persistence unit
- Missing password provider for password type: ${passwordType}
- The configuration ${clazz} is missing the @ConfigRoot annota
- Unsupported value: ${value}
- Invalid configuration value set for 'quarkus.arc.remove-unus
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/4e59ea583ac51028.
Report an issue: GitHub.