• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

NoClassDefFoundError

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My application is loading a custom handler class which is outside my applications WEB-INF directory. Now this class which i am trying to load is implenting a public interface(<myinterface> present in a jar file in WEB-INF/lib directory of my application.Am getting this NoClassDefFoundError:<pkg_structure>.<myinterface> while trying to load my custom handler class.

But if i put this custom handler class which i am trying to load inside my WEB-INF its working fine.

Now what could be the problem? Somebody please help me out.This is urgent.TIA.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A web application container typically uses multiple ClassLoaders: one to load common libraries, and one to load each application. I don't know if you know anything about how ClassLoaders work, but they're arranged in a tree, and each ClassLoader can ask its parent ClassLoader to find a class for it, but not the other way around: if a class being loaded by a parent ClassLoader depends on a class only accessible by a child ClassLoader, then the needed class won't be found. That's what's happening here: the individual application ClassLoaders are children of the shared library ClassLoader, and so classes loaded by the shared library ClassLoader can't depend on classes loaded from the individual applications.

So you can either put the "shared" library into your web app, or move the interface into the shared library. Just make sure that the shared library doesn't depend on any classes in the web app.

And don't include duplicate class files in both locations -- then you'll really have problems.
 
megha sampath
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for the explanation Ernest.That was really helpful.
 
Yeah. What he said. Totally. Wait. What? Sorry, I was looking at this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic