java.lang.NoSuchMethodError: org.slf4j.helpers.MessageFormatter.format(Ljava/lang/String;Ljava/lang/Object;)
Solution
The Reason for the above error is version mis-match between the various SLF4J API. (e.g. 1.6.x is not backwards compatible with 1.5.x). Make sure you have no duplicate jars in your classpath. If exists exclude them and add these dependencies to your classpath

pom.xml

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.6.2</version>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.6.2</version>
</dependency>

In the above code the Version of API and Implementation should be same(i.e. 1.6.2)

SLF4J is basically an abstraction layer. It is not a logging implementation. It means that if you’re writing a library and you use SLF4J, you can give that library to someone else to use and they can choose which logging implementation to use with SLF4J e.g. log4j or the Java logging API. It helps prevent projects from being dependent on lots of logging APIs just because they use libraries that are dependent on them.

org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class
Sol

  1. @Entity Should be added in the Model class
  2. If you have missed to add the Model class in the xml file
  3. Make sure the annotation is javax.persistence.Entity, and not org.hibernate.annotations.Entity. The former makes the entity detectable.

————————————————————————————————————————————————————-
javax.naming.NoInitialContextException: Need to specify class name in environment or system property
Sol
“I want to find the telephone number for John Smith, but I have no phonebook to look in”.This exception is thrown when no initial context implementation can be created.JNDI (javax.naming) is all about looking up objects or resources from some directory or provider. To look something up, you need somewhere to look (this is the InitialContext).

————————————————————————————————————————————————————-
hibernate exception: org.hibernate.AnnotationException: No identifier specified for entity
Sol

  1. You are missing a field annotated with @Id. Each @Entity needs an @Id – this is the primary key in the database.
  2. If you don’t want your entity to be persisted in a separate table, but rather be a part of other entities, you can use @Embeddable instead of @Entity.
  3. If you want simply a data transfer object to hold some data from the hibernate entity, use no annotations on it whatsoever – leave it a simple pojo.

————————————————————————————————————————————————————-
org.hibernate.hql.internal.ast.QuerySyntaxException: table is not mapped
Sol
In the HQL , you should use the java class name and property name of the mapped @Entity instead of the actual table name and column name

For example if your bean class name is UserDetails then the Hibernate code should be as below.Not Tbl_UserDetails instead of UserDetails

 Query query = entityManager. createQuery("Select UserName from UserDetails"); 

The problem can also be because of wrong import

import javax.persistence.Entity;

instead of

import org.hibernate.annotations.Entity;

————————————————————————————————————————————————————-