Intellij IDEA 报错java.lang.NoClassDefFoundError

Posted 邦☆杠

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Intellij IDEA 报错java.lang.NoClassDefFoundError相关的知识,希望对你有一定的参考价值。

Intellij IDEA 报错java.lang.NoClassDefFoundError

11-Aug-2018 23:48:24.686 严重 [http-nio-8080-exec-5] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [com.wbg.testservlet] in context with path [] threw exception [Servlet execution threw an exception] with root cause

 java.lang.ClassNotFoundException: com.wbg.testDao

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1291)

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)

at com.wbg.testService.select(testService.java:9)

at com.wbg.testservlet.doGet(testservlet.java:19)

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

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

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

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

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

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

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

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

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

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)

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

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

at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)

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

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

at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)

at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)

at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)

at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)

at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

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

 

原因没有导入完整的jar包

 

解决方案:

方案一:

其实是因为jar包未被部署,那么在进行页面请求的时候,就会找不到jar包,那么就会报错….. 
解决方案如下: 
Projecture—>Artifacts–>选择打包部署项目—->Output Layout–>Web-INF—->查看下面是否有lib目录(如果没有lib目录,可自行创建)—>右边的jar包添加到lib目录下 
以上,即可解决ClassNotFound的异常 

方案二:

右键->F4进入,看到有报错,然后一直Add到没有就可以了,看图

 

 

 

 

成功解决

 

以上是关于Intellij IDEA 报错java.lang.NoClassDefFoundError的主要内容,如果未能解决你的问题,请参考以下文章

错误记录IntelliJ IDEA 编译 Groovy 项目报错 ( gradle-resources-test:XX: java.lang.NoClassDefFoundError: org )

java.lang.Exception:没有找到匹配使用 Intellij IDEA 的方法的测试

我在 IntelliJ IDEA 和 TomCat 中收到 java.lang.NullPointerException [重复]

IntelliJ IDEA中运行Tomcat报内存溢出(java.lang.OutOfMemoryError: PermGen space)

IntelliJ IDEA中运行Tomcat报内存溢出(java.lang.OutOfMemoryError: PermGen space)

IntelliJ IDEA的Maven项目在修改时报java.lang.OutOfMemoryError: PermGen space异常