This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Problem with session 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 with session" Watch "Problem with session" New topic

Problem with session

ramusrila reddy

Joined: May 06, 2004
Posts: 1
i am new user of hibernate.
when i am tryimng to connect to the back end its giving this exception.
my code is look like this
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.MappingException;
import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.cfg.Configuration;
import net.sf.hibernate.*;
import java.util.*;
public class HibernateUtil{

public void connect() throws HibernateException
System.out.println("Class claeed");

Configuration cfg = new Configuration();

System.out.println("Confg over");
SessionFactory sf = cfg.configure().buildSessionFactory();

System.out.println("Session Over");

Session hSession = sf.openSession();//Exception is rising over here

System.out.println("Session open");

Query q = hSession.createQuery("from emp e");
System.out.println("Query Fired");


List l=q.list();
Emp emp= (Emp)l.get(0);
System.out.println("Emp Name==>"+emp.getName());

}catch(Exception e)


public static void main(String[] args)
HibernateUtil utl=new HibernateUtil();
}catch(Exception e)



Java.lang.NoClassDefFoundError: javax/transaction/Synchronization
at net.sf.hibernate.impl.SessionFactoryImpl.openSession(
at net.sf.hibernate.impl.SessionFactoryImpl.openSession(
at net.sf.hibernate.impl.SessionFactoryImpl.openSession(
at HibernateUtil.connect(
at HibernateUtil.main(
Exception in thread "main"
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Looks like a classpath issue ramusrila reddy. Make sure you have J2EE.jar in your classpath.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
I agree. Here's the link:
subject: Problem with session
It's not a secret anymore!