已有51人关注
第三方jar包添加到指定的相关类库中,tomcat服务能正常启动,但程序运行时,总是提示找不到相关类文件。
发表在JavaWeb答疑区 2017-06-29
是否精华
版块置顶:

老师,您好!我将操作Java Web开发实战1200例(第1卷)的246实例,dom4j-1.6.1.jar包也打上了,服务也正常启动了,但程序运行就报错。实例191也是同样,会不会我哪里配置不对啊,请老师帮助答疑啊,谢谢!实例246的错误提示如下:

2017-6-29 9:35:20 org.apache.catalina.core.StandardWrapperValve invoke

严重: Servlet.service() for servlet KeyServlet threw exception

java.lang.ClassNotFoundException: org.dom4j.DocumentHelper

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

at com.ch01.KeyServlet.getKey(KeyServlet.java:37)

at com.ch01.KeyServlet.doPost(KeyServlet.java:67)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)

at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)

at java.lang.Thread.run(Thread.java:619)


分享到:
精彩评论 7
无语_mrkj
学分:3155 LV11
2017-06-30
沙发

从这个提示看,是找DOM4J组件,这个实例应该是不需要使用DOM4J组件的,您可以清理一下Tomcat的工作路径。在Eclipse的servers选项卡中,创建的服务器 上,单击鼠标右键,选择Clean试试,如果仍然不好使,可以选择Add and Remove移除除了要运行的实例外的其他的实例再试试。

出现这个问题,可能是缓存的问题。

jzy81208
学分:71 LV3
2017-06-30
板凳

老师,还是不行啊。我所有实例都清除,就增加了运行的实例,还是同样的错。我现在把实例191的错误提示贴出来。请老师百忙中帮看一下啊,十分感谢!

2017-6-30 15:49:30 org.apache.catalina.core.StandardWrapperValve invoke

严重: Servlet.service() for servlet jsp threw exception

java.lang.NoClassDefFoundError: org/apache/commons/io/IOUtils

at org.apache.commons.fileupload.util.Streams.copy(Streams.java:123)

at org.apache.commons.fileupload.util.Streams.copy(Streams.java:70)

at org.apache.commons.fileupload.MultipartStream.readBodyData(MultipartStream.java:593)

at org.apache.commons.fileupload.MultipartStream.discardBodyData(MultipartStream.java:617)

at org.apache.commons.fileupload.MultipartStream.skipPreamble(MultipartStream.java:634)

at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.findNextItem(FileUploadBase.java:1023)

at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.<init>(FileUploadBase.java:1003)

at org.apache.commons.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:310)

at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:334)

at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:288)

at com.count.Online.UploadRw.<init>(UploadRw.java:41)

at com.count.Online.UploadFilter.doFilter(UploadFilter.java:20)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)

at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)

at java.lang.Thread.run(Thread.java:619)


无语_mrkj
学分:3155 LV11
2017-06-30
地板

jzy81208 发表于2017-06-30 15:54

老师,还是不行啊。我所有实例都清除,就增加了运行的实例,还是同样的错。我现在把实例191的错误提示贴出来。请老师百忙中帮看一下啊,十分感谢!

2017-6-30 15:49:30 org.apache.catalina.core.StandardWrapperValve invoke

严重: Servlet.service() for servlet jsp threw exception

java.lang.NoClassDefFoundError: org/apache/commons/io/IOUtils

at org.apache.commons.fileupload.util.Streams.copy(Streams.java:123)

at org.apache.commons.fileupload.util.Streams.copy(Streams.java:70)

at org.apache.commons.fileupload.MultipartStream.readBodyData(MultipartStream.java:593)

at org.apache.commons.fileupload.MultipartStream.discardBodyData(MultipartStream.java:617)

at org.apache.commons.fileupload.MultipartStream.skipPreamble(MultipartStream.java:634)

at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.findNextItem(FileUploadBase.java:1023)

at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.<init>(FileUploadBase.java:1003)

at org.apache.commons.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:310)

at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:334)

at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:288)

at com.count.Online.UploadRw.<init>(UploadRw.java:41)

at com.count.Online.UploadFilter.doFilter(UploadFilter.java:20)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)

at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)

at java.lang.Thread.run(Thread.java:619)


在使用commons-fileupload.jar包时,可能还需要辅助使用对应版本的commons-io.jar。您下载一下试试。

jzy81208
学分:71 LV3
2017-06-30
4L

谢谢老师,实例191的可以了。但实例246还是提示java.lang.ClassNotFoundException: org.dom4j.DocumentHelper

java.lang.ClassNotFoundException: org.dom4j.DocumentHelper

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

at com.ch01.KeyServlet.getKey(KeyServlet.java:37)

at com.ch01.KeyServlet.doPost(KeyServlet.java:67)

麻烦老师有空看一下,太打扰你们了,真不好意思。

无语_mrkj
学分:3155 LV11
2017-07-03
5L

jzy81208 发表于2017-06-30 16:58

谢谢老师,实例191的可以了。但实例246还是提示java.lang.ClassNotFoundException: org.dom4j.DocumentHelper

java.lang.ClassNotFoundException: org.dom4j.DocumentHelper

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

at com.ch01.KeyServlet.getKey(KeyServlet.java:37)

at com.ch01.KeyServlet.doPost(KeyServlet.java:67)

麻烦老师有空看一下,太打扰你们了,真不好意思。

刚刚测试了一下,这个程序还真得用Dom4J的Jar包,我用附件中的Jar包测试的,可以运行。您把附件解压缩,再用里面的Jar包试试。dom4J.rar


jzy81208
学分:71 LV3
2017-07-03
6L

好的,谢谢老师!

无语_mrkj
学分:3155 LV11
2017-07-04
7L

jzy81208 发表于2017-07-03 20:52

好的,谢谢老师!

不用客气,

首页上一页 1 下一页尾页 7 条记录 1/1页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照