kk3239226441 2018-03-09 07:44 采纳率: 0%
浏览 1870
已结题

我在用solrj写一个简单的添加索引的测试方法报错

配置是jdk1.8,tomcat9,solr6.6.2,myEclipse2016 ci。
测试方法是
@Test
public void testAdd(){
final String solrUrl="http://127.0.0.1:8080/solr/index.html/core_demo";
HttpSolrClient solrClient = new HttpSolrClient(solrUrl);
//SolrClient solrClient = new HttpSolrClient.Builder(solrUrl).build();
if(solrClient==null)
System.out.println("solrClient is null");
else
System.out.println("solrClient is not null");
SolrInputDocument doc = new SolrInputDocument();
try {
doc.addField("id", "12");
doc.addField("business_name", "哇哈哈");
doc.addField("business_type", "饮料");
doc.addField("business_description", "国产饮料");
solrClient.add(doc);
solrClient.commit();
System.out.println("添加成功");
} catch (Exception e) {
System.out.println("添加失败");
e.printStackTrace();

}
}
结果是
log4j:WARN No appenders could be found for logger (org.apache.solr.client.solrj.impl.HttpClientUtil).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
solrClient is not null
添加失败
org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:
Error from server at http://127.0.0.1:8080/solr/index.html/core_demo:
Expected mime type application/octet-stream but got text/html.
<!doctypehtml>

HTTP Status 404 – Not Found h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a{color:black;}a.name{color:black;}.line{height:1px;background-color:#525D76;border:none;}

HTTP Status 404 – Not Found



Type Status Report

Message /solr/index.html/core_demo/update

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.


Apache Tomcat/9.0.0.M26


at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:580)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:279)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:268)
at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:160)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:173)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:138)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:152)
at com.it.solrj.SolrJManger.testAdding(SolrJManger.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
我用的Junit测试的,它报错说多出了一个html文件,请问我在哪能找到这个文件,还有该怎么办?非常感谢。还有请教能让junit方法通过的办法。
  • 写回答

2条回答 默认 最新

  • kun_hello 2018-03-09 08:39
    关注

    solrClient is not null
    String solrUrl="http://127.0.0.1:8080/solr/index.html/core_demo"; 这个地址有没有开启?

    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序