File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Problem using Annotations in hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Problem using Annotations in hibernate" Watch "Problem using Annotations in hibernate" New topic

Problem using Annotations in hibernate

Hari Dhanakoti
Ranch Hand

Joined: Jan 07, 2008
Posts: 74

I was trying to get the hibernate sample program running with Annotations. I got sample working fine when it is executed with a *.hbm.xml file. I minimized the usage of hbm.xml file. I get a error as mentioned below. Please check out the error and suggest me how to make it working.

Results with an error :

INFO [Configuration] Configured SessionFactory: null
ERROR [STDERR] Initial SessionFactory creation org.hibernate.validator.event.ValidateEventListener
INFO [[/Hibernate_with_Annotations]] Marking servlet createServlet as unavailable
ERROR [[createServlet]] Allocate exception for servlet createServlet
java.lang.ClassCastException: org.hibernate.validator.event.ValidateEventListener at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(


Rachel Swailes
Ranch Hand

Joined: May 18, 2004
Posts: 434
Hi there

In the Hibernate Annotations documentation it says that you should use the fully qualified path name with the addPackage method. Is "events" the fully qualified name?

Might not be the solution but couldn't hurt to check.

Other questions are - what version of Annotations are you using and are you using this with JBoss?


Hari Dhanakoti
Ranch Hand

Joined: Jan 07, 2008
Posts: 74
Let me little a bit clear with my doubt

Is Hibernate possible without the help of *.hbm.xml files ? If so how to get that done ? any samples please.
I am really tired on heading to solve this doubt.
tabiul mahmood

Joined: Sep 17, 2009
Posts: 18
Yes, you can use annotation if you do not want to use hbm.xml file. Please refer to this link for more information of annotation
Hari Dhanakoti
Ranch Hand

Joined: Jan 07, 2008
Posts: 74
Thanks tabiul mahmood !!
let me try to execute the code..
I agree. Here's the link:
subject: Problem using Annotations in hibernate
jQuery in Action, 3rd edition