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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:42:47+00:00 2026-05-16T20:42:47+00:00

I am using Spring MVC and Hibernate. I want to use the OpenSessionInViewFilter to

  • 0

I am using Spring MVC and Hibernate.

I want to use the OpenSessionInViewFilter to allow lazy loading to work properly in the view layer.

The OpenSessionInViewFilter requires a root application context so i added a ContextLoaderListener and moved my non view related configuration files to it from the DispatcherServlet.

The app-config.xml config file contains the datasource related beans.

When i load the app-config.xml using the ContextLoaderListener instead of DispatcherServlet, i get the error message

WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/XXXX/app/jobs] in DispatcherServlet with name 'Spring MVC Dispatcher Servlet'

UPDATE: fixed this error by adding a component-scan to mvc-config.xml

but now i get

org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here

My understanding is that DispatcherServlet inherits beans from the root context, so moving definitions from the servlet to the root context should make no difference.

web.xml

<filter>
  <filter-name>UrlRewriteFilter</filter-name>
  <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
 </filter>

 <filter-mapping>
  <filter-name>UrlRewriteFilter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>

 <filter>
  <filter-name>openSessionInViewFilter</filter-name>
  <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
  <init-param>
   <param-name>singleSession</param-name>
   <param-value>true</param-value>
  </init-param>
  <init-param>
   <param-name>flushMode</param-name>
   <param-value>AUTO</param-value>
  </init-param>
  <init-param>
   <param-name>sessionFactoryBeanName</param-name>
   <param-value>sessionFactory</param-value>
  </init-param>
 </filter>

 <filter-mapping>
  <filter-name>openSessionInViewFilter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>

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

 <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>
   /WEB-INF/spring/app-config.xml
   /WEB-INF/spring/other-config.xml
  </param-value>
 </context-param>

 <!-- Handles all requests into the application -->
 <servlet>
  <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <init-param>
   <param-name>contextConfigLocation</param-name>
   <param-value>
    /WEB-INF/spring/mvc-config.xml
   </param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
 </servlet>

 <!-- Maps all /app requests to the DispatcherServlet for handling -->
 <servlet-mapping>
  <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
  <url-pattern>/app/*</url-pattern>
 </servlet-mapping>

app-config.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"
 xmlns:tx="http://www.springframework.org/schema/tx"
 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-3.0.xsd
  http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

 <!--
  Scans within the base package of the application for @Components to
  configure as beans
 -->
 <context:component-scan base-package="com.mycompany.app" />

 <!-- SQL Server -->
 <bean id="datasource" class="org.apache.commons.dbcp.BasicDataSource"
  destroy-method="close">
  <property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver" />
  <property name="url" value="jdbc:jtds:sqlserver://x.x.x.x/XXX" />
  <property name="username" value="XXX" />
  <property name="password" value="XXX" />
 </bean>

 <bean id="sessionFactory"
  class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  <property name="dataSource" ref="datasource" />
  <property name="configLocation">
   <value>/WEB-INF/hibernate.cfg.xml</value>
  </property>
  <property name="configurationClass">
   <value>org.hibernate.cfg.AnnotationConfiguration</value>
  </property>
  <property name="hibernateProperties">
   <value>hibernate.dialect=org.hibernate.dialect.SQLServerDialect</value>
  </property>
 </bean>

 <tx:annotation-driven />

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

</beans>

mvc-config.xml

<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
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-3.0.xsd
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

<!-- Configures support for @Controllers -->
<mvc:annotation-driven />

<context:component-scan base-package="com.mycompany.app" />

 <bean id="tilesConfigurer"
  class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
  <property name="definitions">
   <list>
    <value>/WEB-INF/defs/general.xml</value>
   </list>
  </property>
 </bean>

 <bean id="viewResolver"
  class="org.springframework.web.servlet.view.UrlBasedViewResolver">
  <property name="viewClass"
   value="org.springframework.web.servlet.view.tiles2.TilesView" />
 </bean>

</beans>
  • 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-16T20:42:48+00:00Added an answer on May 16, 2026 at 8:42 pm

    One possible problem I can see here is that openSessionInViewFilter is mapped after UrlRewriteFilter. UrlRewriteFilter performs RequestDispatcher.forward(), therefore all filters mapped after it should have <dispatcher>FORWARD</dispatcher>:

    <filter-mapping> 
        <filter-name>openSessionInViewFilter</filter-name> 
        <url-pattern>/*</url-pattern> 
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Spring MVC web-application. I want to use Hibernate and AJAX. There are
I am using Spring MVC with Hibernate. My page has a button that creates
I am creating a Spring MVC Hibernate application using MySQL. Where should I save
I'm working on a Spring MVC project in which I'm using Hibernate Validator to
I am building web application using Spring MVC Spring Security Hibenate MySQl I want
I am using Spring Web MVC and Hibernate for developing my application. My login.jsp
We are currently using Spring MVC to implement REST web services. We now want
I'm using Hibernate Validator in an application with EJB and Spring MVC. I'm using
I am using Web Flow 2.0.7 with Spring MVC and Hibernate. My problem is
I work on an application that uses Spring MVC and Hibernate. I am implementing

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.