Getting ClassCastException while building the Hibernate Session Factory
posted 4 years ago
I am getting ClassCastException while building the hibernate session factory.
The hibernate session factory gets built without any error on my local setup which is exactly same as prod setup.
However this error does not occures always. The hibernate session factory gets built always but sometimes I get to see this error in the tomcat logs and thus my application stops working.
As a workaround we take a reboot on the tomcat server and the problem gets solved.
Below is the code I use for getting sessions from the session factory.
The exception I receive in the logs is
I don't understand why this is happening. The same tomcat also runs some other applications.
Can this be due to some other application. This is just a guess. I am not sure of this.
Further in the exception logs provided above, I see a statement saying
Could not read mappings from resource: File.hbm.xml
Duplicate class/entity mapping com.yyyy.transcript.File
Is it because the HibernateSessionFactory.class may be calling a rebuildSessionFactory method().
Your help in this regard is very much appreciated.