Early log entry for async EntityManagerFactory initialization failure

Closes gh-26093
This commit is contained in:
Juergen Hoeller
2020-11-13 17:59:14 +01:00
parent 40a79a87ae
commit dc8a776cae

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -193,8 +193,8 @@ public abstract class AbstractEntityManagerFactoryBean implements
* {@code Persistence.createEntityManagerFactory} (if any). * {@code Persistence.createEntityManagerFactory} (if any).
* <p>Can be populated with a String "value" (parsed via PropertiesEditor) or a * <p>Can be populated with a String "value" (parsed via PropertiesEditor) or a
* "props" element in XML bean definitions. * "props" element in XML bean definitions.
* @see javax.persistence.Persistence#createEntityManagerFactory(String, java.util.Map) * @see javax.persistence.Persistence#createEntityManagerFactory(String, Map)
* @see javax.persistence.spi.PersistenceProvider#createContainerEntityManagerFactory(javax.persistence.spi.PersistenceUnitInfo, java.util.Map) * @see javax.persistence.spi.PersistenceProvider#createContainerEntityManagerFactory(PersistenceUnitInfo, Map)
*/ */
public void setJpaProperties(Properties jpaProperties) { public void setJpaProperties(Properties jpaProperties) {
CollectionUtils.mergePropertiesIntoMap(jpaProperties, this.jpaPropertyMap); CollectionUtils.mergePropertiesIntoMap(jpaProperties, this.jpaPropertyMap);
@@ -204,8 +204,8 @@ public abstract class AbstractEntityManagerFactoryBean implements
* Specify JPA properties as a Map, to be passed into * Specify JPA properties as a Map, to be passed into
* {@code Persistence.createEntityManagerFactory} (if any). * {@code Persistence.createEntityManagerFactory} (if any).
* <p>Can be populated with a "map" or "props" element in XML bean definitions. * <p>Can be populated with a "map" or "props" element in XML bean definitions.
* @see javax.persistence.Persistence#createEntityManagerFactory(String, java.util.Map) * @see javax.persistence.Persistence#createEntityManagerFactory(String, Map)
* @see javax.persistence.spi.PersistenceProvider#createContainerEntityManagerFactory(javax.persistence.spi.PersistenceUnitInfo, java.util.Map) * @see javax.persistence.spi.PersistenceProvider#createContainerEntityManagerFactory(PersistenceUnitInfo, Map)
*/ */
public void setJpaPropertyMap(@Nullable Map<String, ?> jpaProperties) { public void setJpaPropertyMap(@Nullable Map<String, ?> jpaProperties) {
if (jpaProperties != null) { if (jpaProperties != null) {
@@ -400,10 +400,13 @@ public abstract class AbstractEntityManagerFactoryBean implements
String message = ex.getMessage(); String message = ex.getMessage();
String causeString = cause.toString(); String causeString = cause.toString();
if (!message.endsWith(causeString)) { if (!message.endsWith(causeString)) {
throw new PersistenceException(message + "; nested exception is " + causeString, cause); ex = new PersistenceException(message + "; nested exception is " + causeString, cause);
} }
} }
} }
if (logger.isErrorEnabled()) {
logger.error("Failed to initialize JPA EntityManagerFactory: " + ex.getMessage());
}
throw ex; throw ex;
} }