在 Web 应用程序中将 Maven 与 Eclipse 一起使用时抛出异常
我想根据本教程使用maven与eclipse集成来开发webapp: http://jacksonps4.me/wordpress /?p=868
但是当我打开jsp页面时,它抛出NullPointerException如下
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at org.apache.jsp.index_jsp._jspInit(index_jsp.java:23)
at org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52)
at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:164)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:338)
我用google搜索了这个bug,似乎这是由于将jsp-api.jar放在WEB-INF/lib下引起的
但实际上我没有这样做,即使当我从maven中移动jsp-api依赖项时,异常仍然出现。我该如何解决?
I want to use maven integrated with eclipse to develop webapp according this tutorial: http://jacksonps4.me/wordpress/?p=868
But when I open jsp page, it throw NullPointerException as following
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at org.apache.jsp.index_jsp._jspInit(index_jsp.java:23)
at org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52)
at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:164)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:338)
I googled this bug, it seems that this is caused by put jsp-api.jar under WEB-INF/lib
But actually I did not do that, even when I move the jsp-api dependency from maven, the exception still come out. How can I solve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也可能是由于将其放在机器的 JDK/JRE 的 lib 文件夹中而引起的,该文件夹也被 webapp 的运行时类路径覆盖。它也可能是由于运行时类路径中某处的不同 servletcontainer make/version 中的
servlet-api
造成的。我不使用 Maven,但我相信您必须将它们指定为
provided
范围,以免它们最终出现在/WEB-INF/lib
中构建。It can also be caused by putting it in lib folder of the JDK/JRE of the machine, which is also covered by the webapp's runtime classpath. It can also be caused by having
servlet-api
from a different servletcontainer make/version somewhere in the runtime classpath.I don't do Maven, but I believe that you have to specify them as
provided
scope in order to not have them to end up in/WEB-INF/lib
of the build.