我在学习servlet与jsp核心编程这本书时,编写书中的例子。使用jakarta通用库中的BeanUtils组件,来处理参数的自动填充问题。
我按照书中介绍,分别下载了3个必须的组件。
commons-beanutils.jar
commons-collections-3.2.jar
commons-logging-1.1.jar
并放在
Tomcat_install_dir/lib下,
但是在我调试是出现未找到类错误。
错误提示如下:
exception
javax.servlet.ServletException: Servlet execution threw an exception
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
root cause
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
org.apache.commons.beanutils.ConvertUtilsBean.<init>(ConvertUtilsBean.java:157)
org.apache.commons.beanutils.BeanUtilsBean.<init>(BeanUtilsBean.java:117)
org.apache.commons.beanutils.BeanUtilsBean$1.initialValue(BeanUtilsBean.java:68)
org.apache.commons.beanutils.ContextClassLoaderLocal.get(ContextClassLoaderLocal.java:153)
org.apache.commons.beanutils.BeanUtilsBean.getInstance(BeanUtilsBean.java:80)
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:433)
coreservlets.beans.BeanUtilities.populateBean(BeanUtilities.java:52)
coreservlets.beans.BeanUtilities.populateBean(BeanUtilities.java:40)
coreservlets.SubmitInsuranceInfo.processRequest(SubmitInsuranceInfo.java:37)
coreservlets.SubmitInsuranceInfo.doGet(SubmitInsuranceInfo.java:73)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
root cause
java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
java.net.URLClassLoader$1.run(URLClassLoader.java:202)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(URLClassLoader.java:190)
sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
java.lang.ClassLoader.loadClass(ClassLoader.java:307)
java.lang.ClassLoader.loadClass(ClassLoader.java:248)
org.apache.commons.beanutils.ConvertUtilsBean.<init>(ConvertUtilsBean.java:157)
org.apache.commons.beanutils.BeanUtilsBean.<init>(BeanUtilsBean.java:117)
org.apache.commons.beanutils.BeanUtilsBean$1.initialValue(BeanUtilsBean.java:68)
org.apache.commons.beanutils.ContextClassLoaderLocal.get(ContextClassLoaderLocal.java:153)
org.apache.commons.beanutils.BeanUtilsBean.getInstance(BeanUtilsBean.java:80)
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:433)
coreservlets.beans.BeanUtilities.populateBean(BeanUtilities.java:52)
coreservlets.beans.BeanUtilities.populateBean(BeanUtilities.java:40)
coreservlets.SubmitInsuranceInfo.processRequest(SubmitInsuranceInfo.java:37)
coreservlets.SubmitInsuranceInfo.doGet(SubmitInsuranceInfo.java:73)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
分割线 参考网上的建议,classpath也应该正确引用了3个jar包。 请问如何解决呢?