Hi,
I'm a total newbie on Hibernate and I'm starting to thing that I must also be very stupid:)
How come is it possible that I get this "java.lang.NoClassDefFoundError: net/sf/hibernate/HibernateException" -exception on classes that don't use any Hibernate-related classes? They just call a class that fetches data from Oracle using Hibernate.
Here is the code that uses Hibernate:
Code:
public class MenuItems {
public Materialclass[] getMaterialclasses() throws Exception {
try {
Session session = HibernateUtil.currentSession();
Materialclass[] classes;
Transaction tx= session.beginTransaction();
List list = session.find("from Materialclass matClass order by matClass.definition");
tx.commit();
classes = (Materialclass[]) list.toArray();
return classes;
} catch (Exception ex) {
System.out.println(ex.getMessage());
ex.printStackTrace();
return null;
} finally {
try {
HibernateUtil.closeSession();
} catch (HibernateException e) {
throw new Exception(e);
}
}
}
}
It is called from here:
Code:
public void init() {
int ii = 1;
Materialclass[] classes;
MenuItems items = new MenuItems();
try {
classes = items.getMaterialclasses();
setMatclassValues(0, classes[0].getDefinition());
setMatclassKeys(0, classes[0].getMaterialclass().toString());
for(int i = 1; i < classes.length; i++) {
if(!classes[i].getDefinition().equals(this.getMatclassValues(i-1))) {
System.out.println("class:" + classes[i].getDefinition());
setMatclassValues(ii, classes[i].getDefinition());
setMatclassKeys(ii, classes[i].getMaterialclass().toString());
ii++;
}
}
} catch (Exception e) {
;
}
}
The exception is thrown at line "MenuItems items = new MenuItems();". I am using Hibernate 2.1.1 and Tomcat 5.0.16. HibernateUtil.class is just like in
http://www.hibernate.org/hib_docs/reference/html/quickstart.html
Any help is very welcome.
thanks,
Jari[url][/url]