获取HTTP状态500 - Servlet执行引发异常

时间:2017-08-24 22:29:27

标签: java tomcat

我创建了一个动态Web项目,其中输入参数来自UI(Index.html)转到servlet.java,但是当我尝试在oAuthBean.java文件中调用auth时,它给了我一个错误

附加导航视图:

enter image description here

例外:

Aug 24, 2017 3:18:42 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [clientCredServlet1] in context with path [/Java-Credit-Offers-Example] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: org.apache.http.HttpEntity
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
    at controller.clientCredServlet.doPost(clientCredServlet.java:45)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495)
    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:748)

1 个答案:

答案 0 :(得分:1)

看起来你的servlet使用Apache http客户端(那里是org.apache.http.HttpEntity来自哪里),但是在最终部署中没有相应的依赖jar,很可能是因为Maven和Eclipse之间缺少配置粘合剂WTP插件,它从IDE部署并运行您的Tomcat。出现这种缺陷是因为看起来Maven项目是在Eclipse之外创建的。

选项1.保持原样并执行quickfix(更糟)

尝试在项目根文件夹下执行:

mvn eclipse:eclipse -Dwtpversion=2.0

然后重新打开Eclipse工作区

根据Maven Eclipse plugin documentation显式设置wtpversion标志时,maven为WTP插件(包括Tomcat插件)生成必要的工作空间配置,以便让他们了解如何在Eclipse部署期间获取Maven依赖关系

选项2.依靠与Maven的内置IDE集成(最适合长期使用)

检查following great answer,在某种程度上,它描述了为什么以及如何依赖内置 Eclipse Maven支持。这种方法也消除了IDE部署中缺少依赖关系的问题,但是需要更多的努力才能将项目迁移到项目中,但是当项目处于开始阶段时这是非常小的