I am addinng data to index in my solr server using a java client program. My source looks like:-
SolrServer solrServer = new HttpSolrServer("http://10.219.224.91:4040/solr/test");
System.out.println("<ul>");
String[] passengerType={"Infant","Handicapped","Unaccompanied minor", "General Category"};
for(int i = 0; i < 100; i++) {
SolrInputDocument solrInputDocument = new SolrInputDocument();
solrInputDocument.addField("id", new String("widget " + i));
// add three random categories
for(int j = 0; j < 3; j++) {
solrInputDocument.addField("category", passengerType[new Random().nextInt(passengerType.length)]);
}
solrInputDocument.addField("size", new Random().nextInt(10));
// this is cheating below - but saves us from the query string...
solrInputDocument.addField("text", "a");
solrServer.add(solrInputDocument);
System.out.println("<li> Adding: " + solrInputDocument + "</li>\n");
}
System.out.println("</ul>");
solrServer.commit();
While running the application I am getting :-
Exception in thread "main" java.lang.NoClassDefFoundError: org/noggit/CharArr at org.apache.solr.common.util.JavaBinCodec.(JavaBinCodec.java:474) at org.apache.solr.client.solrj.impl.BinaryResponseParser.processResponse(BinaryResponseParser.java:41) at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:407) at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:180) at org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:117) at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:116) at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:102) at IndexDriver.main(IndexDriver.java:39) Caused by: java.lang.ClassNotFoundException: org.noggit.CharArr at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source)
error is coming on this line-
solrServer.add(solrInputDocument);
Any help will be highly appreciated.
2条答案
按热度按时间des4xlb01#
我认为您的程序中没有包含noggit-0.5.jar文件
从http://www.java2s.com/Code/Jar/n/Downloadnoggit05jar.htm下载
或Maven-Repository
然后将其导入到项目库中。
2nbm6dog2#
您还可以使用solr framework中提供的jar。
例如,如果您使用的是solr4.7.2,并且这些jar文件位于solr-4.7.2\dist\solrj-lib\