I am implementing the ServletContextListener:
public class Listener implements ServletContextListener {
public void contextInitialized(ServletContextEvent arg0) {
ServletContext context=arg0.getServletContext();
try {
XMLInputSource in = new XMLInputSource("/home/ahmed/Desktop/AE.xml");
} catch (IOException e) {
}
}
}
Where XMLInputSource is defined in an external jar; that is included into the project (on Eclipse).
However, trying to use this external class, results in an exception:
java.lang.NoClassDefFoundError
Any help? does Tomcat require registering the used external libraries, in a special way??
Webapp libraries must be stored in the /WEB-INF/lib directory of the deployed web application. In a WTP eclipse project, you just have to drop the jar in the WebContent/WEB-INF/lib folder, and this jar will automatically be
So, remove it from your build path, and drop it in WebContent/WEB-INF/lib.
And please, don’t swallow exceptions like you’re doing in your code snippet! If you can’t throws IOException, at least throw a runtime exception wrapping the original IOException.