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 6849013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:56:18+00:00 2026-05-27T00:56:18+00:00

Problem I can’t define a correct sessionFactory bean in my project and fails web

  • 0

Problem

I can’t define a correct sessionFactory bean in my project and fails web application initialization.

Log output

    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webServiceTest' defined in ServletContext resource [/WEB-INF/
classes/appcontext-spring.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate
' is required
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1336)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:471)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
        ... 50 more
Caused by: java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required
        at org.springframework.orm.hibernate3.support.HibernateDaoSupport.checkDaoConfig(HibernateDaoSupport.java:117)
        at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1367)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1333)
        ... 60 more

I’ve created an ORM library with maven using xml mappings and pojos.
I’ve imported into my project and I can’t configure to access into DDBB.

  • jdbc.properties file is well defined with DDBB connection (db.url, db.properties, etc).
  • All POJOs in library extend HibernateDaoSupport and implement basic op interface (CRUD). I’m using a service webServiceTest that extends DaoBase to make a test.
  • I’ve did JUnit tests in ORM-library with good results.

Here is dataSource, sessionFactory, etc definitions from appcontext-persistance.xml file:

    <!-- PERSISTENCE SETUP -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close">
    <property name="driverClassName">
        <value>${db.driver}</value>
    </property>
    <property name="url">
        <value>${db.url}</value>
    </property>
    <property name="username">
        <value>${db.username}</value>
    </property>
    <property name="password">
        <value>${db.password}</value>
    </property>

    <property name="maxActive">
        <value>${db.maxActive}</value>
    </property>

    <!-- Maximum number of idle dB connections to retain in pool. Set 
        to 0 for no limit -->
    <property name="maxIdle">
        <value>${db.maxIdle}</value>
    </property>

    <!-- Maximum time to wait for a dB connection to become available 
        in ms, in this example 10 seconds. An Exception is thrown if this timeout 
        is exceeded. Set to -1 to wait indefinitely. -->
    <property name="maxWait">
        <value>${db.maxWait}</value>
    </property>

    <!-- Autocommit setting. This setting is required to make Hibernate 
        work. Or you can remove calls to commit(). -->
    <property name="defaultAutoCommit">
        <value>true</value>
    </property>

    <!-- Recover abandoned connections -->
    <property name="removeAbandoned">
        <value>true</value>
    </property>

    <!-- Set the number of seconds a dB connection has been idle before 
        it is considered abandoned. -->
    <property name="removeAbandonedTimeout">
        <value>11</value>
    </property>

    <!-- Log a stack trace of the code which abandoned the dB connection 
        resources. -->
    <property name="logAbandoned">
        <value>true</value>
    </property>

</bean>

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

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="lobHandler">
        <ref bean="oracleLobHandler" />
    </property>
    <property name="dataSource" ref="dataSource" />

    <!-- configura la fuente de los mappings -->
    <property name="configLocation" value="classpath:hibernate.cfg.xml" />

    <property name="hibernateProperties">
        <props>

            <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9iDialect</prop>
            <prop key="hibernate.generate_statistics">true</prop>

        </props>
    </property>
</bean>

Questions:

  • Spring configuration has to load hibernate.cfg.xml from ORM jar? How can I do this ?
  • How should I load a configuration from a Spring ORM project into another ?
  • I define the mappings in ORM but I don’t have any application context defined in ORM to include in the jar.
  • 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-27T00:56:19+00:00Added an answer on May 27, 2026 at 12:56 am

    I’ve solve this issue using the attribute for beans tag default-autowire="byName" and it loads all configurations for object injections needed in appcontext-spring.xml.

    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"
        default-lazy-init="true" default-autowire="byName">
    

    And creates the sessionFactory.

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

Sidebar

Related Questions

Which problem can cause kill -9 in production application (in linux to be exact)?
I think that this problem occurs often on a web application development. But I'll
My problem can be readily seen on the following to pages: The correct version
I think that this problem can be sorted using reflection (a technology which I'm
Problem: How can I tell if a selection of text in the CRichEditCtrl has
I have a problem and can't solve it alone. My teacher gives me one
I have a problem - i can't compile SqlCipher. I'm using this http://groups.google.com/group/sqlcipher/browse_thread/thread/55c6296b56bf4533/c792bbec6df7d4f4?tvc=2#c792bbec6df7d4f4 instructions
I've got a problem I can't find any solution for. I have a textfile
there's this interesting problem i can not solve myself. I will be very glad,
this must be such a simple problem but can someone tell me why this

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.