aspose file tools*
The moose likes Object Relational Mapping and the fly likes java.lang.NoClassDefFoundError: org/hibernate/criterion/Criterion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "java.lang.NoClassDefFoundError: org/hibernate/criterion/Criterion" Watch "java.lang.NoClassDefFoundError: org/hibernate/criterion/Criterion" New topic
Author

java.lang.NoClassDefFoundError: org/hibernate/criterion/Criterion

praveen palla
Greenhorn

Joined: Sep 27, 2010
Posts: 2
Hi

i am getting the java.lang.NoClassDefFoundError: org/hibernate/criterion/Criterion error

when i am trying to create object for the OfficesHome .the code has generated from the reverse engineering tool.

blow code is HibernateTemplate generated through the tool.

i also kept the hibernate3.1.1.GA.jar in the class path and build path.

i cant able to solve the error. i attached the code below.any one can help regarding this.

Regards
Praveen


package hibernate;

// default package
// Generated Sep 27, 2010 5:27:22 AM by Hibernate Tools 3.3.0.GA

import java.util.List;
import javax.naming.InitialContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.SessionFactory;
import static org.hibernate.criterion.Example.create;

/**
* Home object for domain model class Offices.
* @see .Offices
* @author Hibernate Tools
*/
public class OfficesHome {

private static final Log log = LogFactory.getLog(OfficesHome.class);

private final SessionFactory sessionFactory = getSessionFactory();

protected SessionFactory getSessionFactory() {
try {
return (SessionFactory) new InitialContext()
.lookup("SessionFactory");
} catch (Exception e) {
log.error("Could not locate SessionFactory in JNDI", e);
throw new IllegalStateException(
"Could not locate SessionFactory in JNDI");
}
}

public void persist(Offices transientInstance) {
log.debug("persisting Offices instance");
try {
sessionFactory.getCurrentSession().persist(transientInstance);
log.debug("persist successful");
} catch (RuntimeException re) {
log.error("persist failed", re);
throw re;
}
}

public void attachDirty(Offices instance) {
log.debug("attaching dirty Offices instance");
try {
sessionFactory.getCurrentSession().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}

public void attachClean(Offices instance) {
log.debug("attaching clean Offices instance");
try {
sessionFactory.getCurrentSession().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}

public void delete(Offices persistentInstance) {
log.debug("deleting Offices instance");
try {
sessionFactory.getCurrentSession().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}

public Offices merge(Offices detachedInstance) {
log.debug("merging Offices instance");
try {
Offices result = (Offices) sessionFactory.getCurrentSession()
.merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}

public Offices findById(java.lang.String id) {
log.debug("getting Offices instance with id: " + id);
try {
Offices instance = (Offices) sessionFactory.getCurrentSession()
.get("Offices", id);
if (instance == null) {
log.debug("get successful, no instance found");
} else {
log.debug("get successful, instance found");
}
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}

public List<Offices> findByExample(Offices instance) {
log.debug("finding Offices instance by example");
try {
List<Offices> results = (List<Offices>) sessionFactory
.getCurrentSession().createCriteria("Offices")
.add(create(instance)).list();
log.debug("find by example successful, result size: "
+ results.size());
return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}
}
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Do you maybe have an older version of Hibernate in your classpath as well?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
praveen palla
Greenhorn

Joined: Sep 27, 2010
Posts: 2
Thanks, I had solved the problem by placing the jars in the LIB folder of web application

i am facing new error

java.lang.IllegalStateException: Could not locate SessionFactory in JNDI
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

That's a completely different error; please start a new thread in... not sure where JNDI stuff goes, the JEE forum?

When you do, please include how you've configured your JNDI resource(s).
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

I think its relevant in this forum, David. The usual cause for this sort of behaviour is a misconfigured SessionFactory. Praveen, can you post any error s you see in your log files - ideally as David asks in a new topic (for clarity's sake)?
 
Don't get me started about those stupid light bulbs.
 
subject: java.lang.NoClassDefFoundError: org/hibernate/criterion/Criterion