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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:57:33+00:00 2026-05-19T01:57:33+00:00

I’ve been everywhere on the web, and i’m little lost and couldn’t solve my

  • 0

I’ve been everywhere on the web, and i’m little lost and couldn’t solve my problem.

I’m creating a web application using Eclipse, with JSP on the client side, and Servet/Hibernate on the server side.
I’m trying to pass an Object to a JSP page form a servlet.

In the servlet :

Contact c = dao.getContact(dataID);

request.setAttribute("data", c);

getServletContext()
    .getRequestDispatcher("/"+url+"?id="+dataID).forward(request, response);

In the JSP page :

Contact contact = (Contact)request.getAttribute("data");

Contact is an ORM, which has attributes like “lastname”.

But i’m getting this error message :

GRAVE: "Servlet.service()" pour la servlet GetData a généré une exception
org.hibernate.HibernateException: No CurrentSessionContext configured!
    at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:683)
    at domain.DAOContact.getContact(DAOContact.java:39)
    at domain.GetData.doGet(GetData.java:27)

So I tried to figure out why, and somewhere I read that I need to set the current session context to “thread” in the hibernate config file. But when I did this, i get this message :

GRAVE: Servlet.service() for servlet [GetData] in context with path [/CarnetContacts] threw exception [org.hibernate.LazyInitializationException: could not initialize proxy - no Session] with root cause
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
    at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:167)
    at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:215)
    at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190)
    at domain.Contact_$$_javassist_1.getLastName(Contact_$$_javassist_1.java)

The second line of the message indicates it has to do with lazy loading, but the last line i shows that the bug occurs when the program is trying to get the “lastname” attribute, which is basically a string, so I don’t think it’s “lazy loaded”.

So if somebody could help me find a solution, that would be very kind.

Code of the dao method :

    public Contact getContact(int contactId){
        Session session = HibernateSessionFactory.getSessionFactory().getCurrentSession();
        Transaction t = session.beginTransaction();
        t.begin();
        Contact contact =(Contact) session.load(Contact.class, new Integer(contactId));
        t.commit();
        return contact; 
    }
  • 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-19T01:57:34+00:00Added an answer on May 19, 2026 at 1:57 am

    Your specific problem in this case is that you use Session.load() instead of Session.get().

    load() returns a lazily-initialized proxy, therefore it should be used only in special cases, in the most cases you need to use get().

    Generally speaking, besides this particular case, problem with lazy initialization in view layer can be solved using one of the following approaches:

    • Use Open Session in View pattern

    • Fetch all required data before rendering the view (using JOIN FETCH, Hibernate.initialize(), etc)

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I've tracked down a weird MySQL problem to the two different ways I was
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.