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

  • Home
  • SEARCH
  • 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 6901957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:44:19+00:00 2026-05-27T07:44:19+00:00

I am getting the following error Exception in thread main java.lang.ClassCastException: org.hibernate.impl.SessionFactoryImpl cannot be

  • 0

I am getting the following error

Exception in thread “main” java.lang.ClassCastException: org.hibernate.impl.SessionFactoryImpl cannot be cast to
in.codejava.spring.withHibernate.customer.dao.impl.HibCustomer at
in.codejava.spring.withHibernate.App.main(App.java:15)

This is the line from my code:

ApplicationContext context= new ClassPathXmlApplicationContext("Spring-Module.xml");
HibCustomer CustomerDao = (HibCustomer) context.getBean("sessionFactory");

What could be the error?

  • 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-27T07:44:20+00:00Added an answer on May 27, 2026 at 7:44 am

    In general it is very likely that object by name “sessionFactory” is not instance of HibCustomer. In your case it is obvious, just look the stack trace. It tells you that you cannot cast instance of org.hibernate.impl.SessionFactoryImpl to in.codejava.spring.withHibernate.customer.dao.impl.HibCustomer.

    Most likely you want to cast it to the SessionFactory and continue from there:

    import org.hibernate.SessionFactory;
    ...
    SessionFactory CustomerDao = (SessionFactory) context.getBean("sessionFactory");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting the following error message : Exception in thread main java.lang.NoClassDefFoundError: LU62XnsCvr (wrong
I'm getting the error: Exception in thread main java.lang.NullPointerException at com.deanchester.minos.utils.DatabaseManager.createTables(DatabaseManager.java:59) at com.deanchester.minos.tests.testAddContestantMethod.main(testAddContestantMethod.java:21) I
I'm getting the following errors: Exception in thread main java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextEntry(HashMap.java:810) at java.util.HashMap$KeyIterator.next(HashMap.java:845)
Am getting following error message on calling WCF service: The formatter threw an exception
I have done simple java app for blackberry, while building am getting following error.
i am geting following error Am i missing some jar file? Exception in thread
I am getting the following error when i tried to run my Java REST
I am getting following error when I am trying to get WebResponse using WebResponse
I am getting following error message when using Doctrine ORM in Codeigniter. ( !
SOLVED in the last answer im getting following error, dunno where and why? cause

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.