Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7022671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:36:44+00:00 2026-05-27T23:36:44+00:00

I have created two transaction managers(one for READ requests and another for READ-WRITE requests)

  • 0

I have created two transaction managers(one for READ requests and another for READ-WRITE requests) and two session factories for the same.

Important snippets are as follows:

<tx:annotation-driven />

<bean id="txManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="SessionFactory" />
</bean>

<bean id="txManagerRead"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="SessionFactory" />
    <qualifier value="READ"/>
</bean>

<bean id="txManagerWrite"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="Session1" />
     <qualifier value="WRITE"/>
</bean>

<bean id="AbstractSessionFactory"
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
    abstract="true">
    <property name="annotatedClasses">
        <list>
.....
....
        </list>
    </property>
    <property name="exposeTransactionAwareSessionFactory">
        <value>true</value>
    </property>
</bean>

<bean id="SessionFactory"
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
    parent="AbstractSessionFactory">
    <property name="hibernateProperties">
        <props>
.........
.........
</props>
</property>
</bean>



<bean id="SessionFactory1"
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
    parent="AbstractSessionFactory">
    <property name="hibernateProperties">
        <props>
.........
.........
</props>
</property>
</bean>

The moment I am trying to create a bean for DAO, like:

<bean id="configurationDAO" class="com.amazon.im.dao.hibernate.ConfigurationDAOImpl">
  <property name="sessionFactory" ref="SessionFactory" />
</bean>

I am getting BeanCreationException with following error message:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘configurationDAO’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: public org.hibernate.SessionFactory com.amazon.im.dao.hibernate.GenericDAOImpl.sessionFactory; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [org.hibernate.SessionFactory] is defined: expected single matching bean but found 2: [SessionFactory, SessionFactory1]

I cannot use LocalSessionFactoryBean because I want to use “annotatedClasses” property.

Any pointers on why is it happening?
Is there anything missing from my side?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:36:45+00:00Added an answer on May 27, 2026 at 11:36 pm

    It look like the sessionFactory property of your GenericDAOImpl class (which I assume is the superclass of ConfigurationDAOImpl?) is annotated with @Autowired. This won’t work because it has two session factories to choose from. Also, you’re manually injecting the correct session factory using <property>, so the @Autowired isn’t necessary.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created two transaction managers(one for READ requests and another for READ-WRITE requests)
I have created two forms in my Windows Application. One Form acts as a
I have created two JavaScript files. One file is "validators.js" and the other is
Well as I have posted earlier too...I have created a site in two languages.One
I have two IDbCommand objects that are created from an NHibernate session, and they
I have two tables user (one) and transaction (many) and I need to get
In my spring configuration I have two transaction managers defined for two different databases.
I have created two files: tunables.h #ifndef TUNABLES_H #define TUNABLES_H void tunables_load_conservative(); void tunables_load_aggressive();
Let's say I have created two objects from class foo and now want to
I'm having a problem with mixing managed and unmanaged code. I have created two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.