Java 使用在ServeltContextListener中外部定义的类
我正在实现ServletContextListener:Java 使用在ServeltContextListener中外部定义的类,java,tomcat,servlets,noclassdeffounderror,Java,Tomcat,Servlets,Noclassdeffounderror,我正在实现ServletContextListener: public class Listener implements ServletContextListener { public void contextInitialized(ServletContextEvent arg0) { ServletContext context=arg0.getServletContext(); try { XMLInputSource
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) {
}
}
}
其中,XMLInputSource
在外部jar中定义;它包含在项目中(在Eclipse上)
但是,尝试使用此外部类,会导致异常: java.lang.NoClassDefFoundError
有什么帮助吗?Tomcat是否需要以特殊方式注册使用过的外部库???Webapp库必须存储在部署的WEB应用程序的/WEB-INF/lib目录中。在WTP eclipse项目中,您只需将jar放在WebContent/WEB-INF/lib文件夹中,这个jar就会自动删除
- 在项目的构建类路径中
- 通过Eclipse在/WEB-INF/lib下部署