This week's book giveaway is in the Testing forum.
We're giving away four copies of Data Structures the Fun Way: An Amusing Adventure with Coffee-Filled Examples and have Jeremy Kubica on-line!
See this thread for details.
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

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: 24204
44
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.
 
Note to self: don't get into a fist fight with a cactus. Command this tiny ad to do it:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic