From 0c0db1b888c60dadf9b3c0e90b2d560def4610cb Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 14 Jun 2011 15:02:40 +0000 Subject: [PATCH] refined EntityManagerFactory proxy exception (SPR-4383) git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4538 50f2f4bb-b051-0410-bef5-90022cba6387 --- .../jpa/AbstractEntityManagerFactoryBean.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/org.springframework.orm/src/main/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBean.java b/org.springframework.orm/src/main/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBean.java index d565298e9e5..d508916fad3 100644 --- a/org.springframework.orm/src/main/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBean.java +++ b/org.springframework.orm/src/main/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2011 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -341,9 +341,23 @@ public abstract class AbstractEntityManagerFactoryBean implements this.plusOperations = getJpaDialect().getEntityManagerFactoryPlusOperations(emf); ifcs.add(EntityManagerFactoryPlusOperations.class); } - return (EntityManagerFactory) Proxy.newProxyInstance( - this.beanClassLoader, ifcs.toArray(new Class[ifcs.size()]), - new ManagedEntityManagerFactoryInvocationHandler(this)); + try { + return (EntityManagerFactory) Proxy.newProxyInstance( + this.beanClassLoader, ifcs.toArray(new Class[ifcs.size()]), + new ManagedEntityManagerFactoryInvocationHandler(this)); + } + catch (IllegalArgumentException ex) { + if (this.entityManagerFactoryInterface != null) { + throw new IllegalStateException("EntityManagerFactory interface [" + this.entityManagerFactoryInterface + + "] seems to conflict with Spring's EntityManagerFactoryInfo mixin - consider resetting the "+ + "'entityManagerFactoryInterface' property to plain [javax.persistence.EntityManagerFactory]", ex); + } + else { + throw new IllegalStateException("Conflicting EntityManagerFactory interfaces - " + + "consider specifying the 'jpaVendorAdapter' or 'entityManagerFactoryInterface' property " + + "to select a specific EntityManagerFactory interface to proceed with", ex); + } + } } /**