作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
您好,当我尝试从我的 servlet 的 get 方法初始化 HttpSolrServer 时遇到了这个奇怪的异常
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/MAVL].[Resteasy]- Servlet.service() for servlet Resteasy threw exception
org.jboss.resteasy.spi.UnhandledException: java.lang.NoClassDefFoundError: org/apache/http/entity/mime/content/ContentBody
at org.jboss.resteasy.core.SynchronousDispatcher.unwrapException(SynchronousDispatcher.java:345)
at org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:321)
at org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:214)
at org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:190)
at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:534)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
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:127)
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:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NoClassDefFoundError: org/apache/http/entity/mime/content/ContentBody
at com.polgar.dipl.index.SolrIndex.init(SolrIndex.java:48)
at com.polgar.dipl.index.SolrIndex.getInstance(SolrIndex.java:42)
at com.polgar.dipl.Articles.getRandomArticles(Articles.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:140)
at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:255)
at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:220)
at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:209)
at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:519)
... 18 more
Caused by: java.lang.ClassNotFoundException: org.apache.http.entity.mime.content.ContentBody
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
... 30 more
第 48 行是我初始化 solr 服务器的地方:
server = new HttpSolrServer(url);
Solr 作为另一个 servlet 在同一个 Tomcat 实例上运行。我这样调用它:
@GET
@Path("/test")
public String getTest() {
SolrIndex s = SolrIndex.getInstance();
s.query()
public class SolrIndex {
private static SolrIndex solrIndex = null;
private static String url = "http://localhost:8080/solr/";
public static HttpSolrServer server = null;
public static SolrIndex getInstance() {
if (server == null)
init();
return solrIndex;
}
private static void init() {
solrIndex = new SolrIndex();
server = new HttpSolrServer(url); //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
server.setSoTimeout(1000); // socket read timeout
server.setConnectionTimeout(1000);
server.setDefaultMaxConnectionsPerHost(20);
server.setMaxTotalConnections(50);
server.setMaxRetries(1); // defaults to 0. > 1 not recommended.
}
谢谢!
最佳答案
这是你的类路径,你需要httpmime-4.0.jar
关于tomcat - java.lang.ClassNotFoundException : org. apache.http.entity.mime.content.ContentBody,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10572854/
我对以前只是纯 HTML 和 Javascript 的现有应用程序进行了一些更改。为了添加服务器端功能,我选择了 ASP.NET,并利用了母版页概念。不幸的是,在一个巨大的 Web 表单上,控件 ID
您好,当我尝试从我的 servlet 的 get 方法初始化 HttpSolrServer 时遇到了这个奇怪的异常 org.apache.catalina.core.ContainerBase.[Ca
我是一名优秀的程序员,十分优秀!