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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:26:42+00:00 2026-05-26T17:26:42+00:00

All, I originally had my setup like this and everything worked as expected. WEB-INF

  • 0

All,

I originally had my setup like this and everything worked as expected.

WEB-INF
|--spring-servlet.xml
|--classes
   |--hibernate-cfg.xml

spring-servlet.xml had

<context:component-scan base-package="foo" />
<tx:annotation-driven/>
<bean id="dataSource" ...
<bean id="sessionFactory" ...
<bean id="transactionManager" ...
<bean ...

hibernate-cfg.xml had

<hibernate-configuration>
  <session-factory>
    <mapping ...

I wanted to add Spring Security to the mix to handle user authentication. To get this to work, I had to refactor some stuff. My new setup looks like this:

WEB-INF
|--spring-servlet.xml
|--classes
   |--datasource-cfg.xml
   |--hibernate-cfg.xml

spring-servlet.xml has

<context:component-scan base-package="foo" />
<bean ...

datasource-cfg.xml has

<tx:annotation-driven/>
<bean id="dataSource" ...
<bean id="sessionFactory" ...
<bean id="transactionManager" ...

hibernate-cfg.xml has

<hibernate-configuration>
  <session-factory>
    <mapping ...

The authentication piece now works, but the previously working pieces no longer work.

I now get the following message:

No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
at org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:63)
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:687)

How can I get my app to work with Spring Security and have all the datasource/hibernate stuff in one place?

  • 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-26T17:26:42+00:00Added an answer on May 26, 2026 at 5:26 pm

    This in the web.xml should be enough.

    <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>
        /WEB-INF/spring-security.xml
        classpath:datasource-cfg.xml
      </param-value>
    </context-param>
    
    <listener>
      <listener-class>
        org.springframework.web.context.ContextLoaderListener
      </listener-class>
    </listener>
    

    I wouldn’t mix-and-match where the config files go, however; IMO it’s best to keep them all in one place, probably on the classpath.

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

Sidebar

Related Questions

I originally had a submit button like this <form action=<?php $self ?> method=post >
I had a machine all setup with VS2010 & a .Net 4 project. I
I originally had written a simple XQuery script: $mediaNodes := doc('/db/portfolio/media_data_101109.xml'), $query := concat('$mediaNodes//media[contains(@product,',$product,')'
NOTE: Originally had this listed as a memory leak. After looking into this deeper,
I originally had all of my modules in one package. I recently created a
Hey all. I'm working on an application that was originally intended for HTML, but
Evidently LINQ's OrderBy had originally been specified as unstable, but by the time of
I'm working on a site in php. Originally I had a lot of html
Well, I had built an application intended for MSSQL, and originally ran it that
This will require a little setup. Trust me that this is for a good

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.