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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:12:43+00:00 2026-05-28T05:12:43+00:00

i am new to Spring and hibernate and i am stuck at this problem.

  • 0

i am new to Spring and hibernate and i am stuck at this problem. i have been searching around for a fix but although there are a lot of questions on this, they do not seem to solve my problem. i am using spring 3.1.0 with hibernate 3.6.9 and making a web application with using spring mvc. After a lot of looking around, i managed to solve it with the following config

web.xml

<listener>
<description>Spring context loader</description>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>WEB-INF/applicationContext.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>


<servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>*.do</url-pattern>
</servlet-mapping>

<filter>
    <filter-name>hibernateFilter</filter-name>
    <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>hibernateFilter</filter-name>
    <url-pattern>*.do</url-pattern>
</filter-mapping>


<welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
</welcome-file-list>

applicationContext.xml

<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>

<!-- Enables the Spring MVC @Controller programming model -->
<mvc:annotation-driven  />
<context:annotation-config/>

<!-- Scans within the base package of the application for @Components to 
    configure as beans -->
<!-- @Controller, @Service, @Configuration, etc. -->
<context:component-scan base-package="com.emumba.cricketcalendar" />



<import resource="hibernate-context.xml"/>

hibernate-context.xml

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

<tx:annotation-driven transaction-manager="transactionManager"/>

<bean id="sessionFactory" 
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="annotatedClasses">
        <list>
            <value>com.emumba.cricketcalendar.domain.Match</value>
            <value>com.emumba.cricketcalendar.domain.Ground</value>
            <value>com.emumba.cricketcalendar.domain.Umpire</value>
            <value>com.emumba.cricketcalendar.domain.Country</value>
            <value>com.emumba.cricketcalendar.domain.CricketStatus</value>
            <value>com.emumba.cricketcalendar.domain.Series</value>
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.hbm2ddl.auto">create</prop>
        </props>
    </property>
</bean>

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

And then i put the @Transactional on my service and this exception was gone. But then my autowiring stops working, the autowired annotation doesn’t work and beans with autowired properties start throwing exception. i remove the @transactional annotation from my service and it again starts working but the “no hibernate session bound to thread ” exception returns

So i am really confused , any help would be greatly appreciated

EDIT Service Code

@Service(value=”calendarManager”)
public class CalendarMangerImpl implements CalendarManager {

@Autowired
@Qualifier("matchDao")
public MatchDaoHibernate matchDao;

@Override
public List<Match> getAllMatches() {
    List<Match> matches=new ArrayList<Match>();
    matches=matchDao.findAll();
    return matches;
}

}

  • 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-28T05:12:44+00:00Added an answer on May 28, 2026 at 5:12 am

    Use the service class with reference to its interface and not the actual class as spring uses interface based proxies by default

    Spring AOP defaults to using standard J2SE dynamic proxies for AOP proxies. This enables 
    any interface (or set of interfaces) to be proxied. 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I stuck with this problem. Used components: Spring 1.2.8, Hibernate 3.2.0 cr1, tomcat, struts,
I am new to Spring and ROO and this Annotation/Aspect hell. I have an
I've been experimenting with hibernate and spring and servlets. Now, I'm stuck. Why am
I am pretty new to hibernate and I am stuck at this exception. As
i am new in integration of jsf 2.0 spring 3.1 and hibernate 4.1. how
I am new to Spring MVC . I have a web application. I have
I am new to spring MVC. i have below project structure. Below are classes:
I am new to Spring Batch. I have following question. I am using Spring
I've been trying to get an NHibernate ICompositeUserType mapping to work. But am stuck
I am stuck at this problem. The code looks ok to me(obviously I am

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.