From 1d26c37b87eb0d7f24fefefa452a3cf83d816287 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 12 Oct 2012 16:26:23 +0200 Subject: [PATCH] Mention matching bean names in exception message in case of non-unique EntityManagerFactory lookup --- .../jpa/support/PersistenceAnnotationBeanPostProcessor.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/org.springframework.orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java b/org.springframework.orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java index 5255b736b4..ff11c6383a 100644 --- a/org.springframework.orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java +++ b/org.springframework.orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java @@ -60,6 +60,7 @@ import org.springframework.orm.jpa.ExtendedEntityManagerCreator; import org.springframework.orm.jpa.SharedEntityManagerCreator; import org.springframework.util.ClassUtils; import org.springframework.util.ObjectUtils; +import org.springframework.util.StringUtils; /** * BeanPostProcessor that processes {@link javax.persistence.PersistenceUnit} @@ -521,7 +522,7 @@ public class PersistenceAnnotationBeanPostProcessor * @throws NoSuchBeanDefinitionException if there is no single EntityManagerFactory in the context */ protected EntityManagerFactory findDefaultEntityManagerFactory(String requestingBeanName) - throws NoSuchBeanDefinitionException{ + throws NoSuchBeanDefinitionException { String[] beanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(this.beanFactory, EntityManagerFactory.class); @@ -535,7 +536,8 @@ public class PersistenceAnnotationBeanPostProcessor } else { throw new NoSuchBeanDefinitionException( - EntityManagerFactory.class, "expected single bean but found " + beanNames.length); + EntityManagerFactory.class, "expected single bean but found " + beanNames.length + ": " + + StringUtils.arrayToCommaDelimitedString(beanNames)); } }