FAQ-junit报错:javax/servlet/jsp/PageContext
来源:互联网 发布:osmo和gopro 知乎 编辑:程序博客网 时间:2024/04/29 22:47
问题:
项目引入junit单元测试时,报错如下:
java.lang.NoClassDefFoundError: javax/servlet/jsp/PageContext
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at org.apache.struts2.StrutsTestCase.initServletMockObjects(StrutsTestCase.java:198)
at org.apache.struts2.StrutsTestCase.setUp(StrutsTestCase.java:186)
at junit.framework.TestCase.runBare(TestCase.java:132)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: javax.servlet.jsp.PageContext
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 28 more
解决方法:
将tomcat下的server jsp相关包(servlet-api.jar和jsp-api.jar包)加入libraries中即可。
右键项目–>Bulid Path–>Configure Build Path–>Libraries–>Add External JARs…–>找到tomcat下lib中对应包,加入即可。如下图:
- FAQ-junit报错:javax/servlet/jsp/PageContext
- JSP页面无故报错 javax.servlet.jsp.PageContext cannot be resolved to a type
- JSP页面无故报错 javax.servlet.jsp.PageContext cannot be resolved to a type
- JSP页面无故报错 javax.servlet.jsp.PageContext cannot be resolved to a type
- jsp页面报错: javax.servlet.jsp.PageContext cannot be resolved to a type
- 报错:javax.servlet.jsp.PageContext cannot be resolved to a type
- 报错:javax.servlet.jsp.PageContext cannot be resolved to a type
- jsp页面报javax.servlet.jsp.PageContext cannot be resolved to a type:
- JSP页面报javax.servlet.jsp.PageContext cannot be resolved to a type 错误
- javax.servlet.jsp.PageContext cannot be resolved
- eclipse报javax.servlet.jsp.PageContext cannot be resolved to a type异常
- 引入javax.servlet.jsp报错
- jsp代码页面报:javax.servlet.jsp.PageContext cannot be resolved to a type错误的解决办法
- javax.servlet.jsp.PageContext cannot be resolved to a type
- javax.servlet.jsp.PageContext cannot be resolved to a type
- javax.servlet.jsp.PageContext cannot be resolved to a type
- javax.servlet.jsp.PageContext cannot be resolved to a type
- javax.servlet.jsp.PageContext cannot be resolved to a type
- 使用Restful api库之后,异常日志不能打印的问题(实习日志)
- Java8新特性——Stream
- 最小二乘法-矩阵求导求解
- 放大镜(商品浏览)
- java MD5 加密
- FAQ-junit报错:javax/servlet/jsp/PageContext
- NumberFormatException相关的error总结
- 005-二分搜索-分治法-《算法设计技巧与分析》M.H.A学习笔记
- 递归算法思想
- webview处理404页面
- 错误总结
- CAS单点登录五-使用http而不是https
- 如何利用花生壳系统嵌入飞鱼星、磊科、TP-LINK和D-LINK路由器
- JS—特殊的对象~函数