Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[Hibernate] NoClassDefFoundError

 
Ritchie Warsi
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm building my first Struts/Tiles/Hibernate application and ran into some problems.

I have a Businessclass that has a method for a List, I call on that method straight in my jsp. This same approach did work on another tutorial I was working on, but in my project now it isn't.

Here is the method in CustomerDAO.java:


This is my accOptions.jsp:


And this is my rather long (sorry for that) HibernateUtil.java:


Now when I call on the jsp page the first time I get:


When I refresh that same page i get same exception but different root cause:


I've googled around, found things about classpaths, libraries and such but as far as I can see all is well.
I've got hibernate2.jar AND cglib-full-2.0.1.jar in my WEB-INF/lib.
In my java files I'm referering to the right classes (otherwise Eclipse would warn me about it), so I'm frustrated out of idea's!

Can anyone help me?
O yeah, using JDK 1.5, Tomcat 5.5.4 and Eclipse/MyEclipse.

Another thing. The first rootcause with line 39 is from the throw/catch at wanting to build a SessionFactory and the second one at CustomerDAO:195 is at the List method at trying to get the HibernateUtil.getSession
[ December 22, 2004: Message edited by: Ritchie Warsi ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NoClassDefFoundError occur because of the class not being in the classpath. Now, Eclipse has the correct classpath. Just because Eclipse doesn't have the problem, doesn't mean that Tomcat has the same classpath. Where in Tomcat do you put your Business object?

Mark
 
Ritchie Warsi
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark, by Business Object what file do you mean/should I look for. You see, I don't know all the terms yet
If you mean my CustomerDAO, it's in my webapps/msl2/WEB-INF/classes/*package name directory structure*
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ritchie Warsi:
Hi Mark, by Business Object what file do you mean/should I look for. You see, I don't know all the terms yet
If you mean my CustomerDAO, it's in my webapps/msl2/WEB-INF/classes/*package name directory structure*


Yes, by business object I mean your object that is causing the NoClassDefFoundError. which means based on the stack trace the CustomerDAO object.

Just out of curiosity, does this class need to be in a jar file in the WEB-INF/classes directory? I don't think so, but it has been a while for me creating any kind of Web App. Not that I did much of it before anyway.

Good Luck

Mark
 
Ritchie Warsi
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Allright I still got this same problem. I restarted the whole project, but the problem remains.
The linenumbers in de stacktrace in the first lines all point out (in the end) to either a get or create session method in my HibernateUtil (see my previous post also). So I'm almost beginning to think that that's the problem.
BUT, I use that same HibernateUtil on a different project, developed under the same circumstances and same tools and showing the data list there works fine!

So pleeeeaasssee someone help me out here!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic