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

The Archive Base Latest Questions

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

I’m using Struts 2.2.1.1 and Hibernate 3.6.2.Final. I’m also using C3P0 for my connection

  • 0

I’m using Struts 2.2.1.1 and Hibernate 3.6.2.Final. I’m also using C3P0 for my connection pool which is running on Tomcat 7.0.11.

I’m having issues where my Hibernate Sessions are not being closed and I’m quickly exceeding the maximum number of open connections as configured in the “hibernate.c3p0.max_size” property.

I think it is because my Hibernate Sessions are opened but never closed. I’m opening Sessions from a SessionFactory that is stored in the ServletContext. I tried closing the session in a finally{} block on my Action class but that throws org.hibernate.LazyInitializationException exceptions.

I did some research and I found the Full Hibernate Plugin approach and also the Open Session in View approach.

I’m assuming this is a common problem and I’d like to get a feel for the most commonly used solution.

Another thing I noticed is the Full Hibernate Plugin supports Struts 2.0.9+ to 2.1.6 but I’m using 2.2.1.1. Not sure if this would be a problem or if the website just hasn’t been updated to list the newer version.

Any input is much appreciated.

  • 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-21T23:44:16+00:00Added an answer on May 21, 2026 at 11:44 pm

    I’ve never used the hibernate plugin, but I would encourage you to adopt the Open Session in View pattern. You definitely want to be closing your sessions.

    One of the most common ways to handle this is to create a session at the start of the request, store it in a thread local, and then close it at the end of the request. This can be done from a Struts interceptor or a servlet filter. Basically:

    public class HibernateSessionInterceptor extends AbstractInterceptor {
        @Override
        public String intercept(final ActionInvocation invocation) throws Exception {
            try {
                // create the session and place it in the ThreadLocal
                return invocation.invoke();
            } finally {
                // close the session and remove it from the ThreadLocal
            }
        }
    }
    

    If you use Google Guice, there is a persistence plugin (guice-persist) that is based on JPA. It uses the same approach, but with a servlet filter.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into

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.