Example of using multiple persistence units with Spring?

Solution Verified - Updated -

Issue

  • The following BeanCreationException is encountered when deploying my Spring based application:

    2010-08-30 09:49:51,155 ERROR [com.example.SomeBean] Unable to start Spring Context
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aBean' defined in class path resource [META-INF/applicationContext.xml]: Cannot resolve reference to bean 'someDao' while setting bean property 'someDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'someDao': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but found 2
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
        ...
    

Environment

  • JBoss Enterprise Application Platform (EAP) 4.3
  • Spring 3.0

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content