2013-10-17 78 views
3

我使用java客戶端程序將索引數據添加到索引服務器中。我的來源是這樣的: -java.lang.NoClassDefFoundError:org/noggit/CharArr同時添加要索引的文檔在solr

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(); 

在運行我得到了應用: -

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)

錯誤是在這個未來LINE-

solrServer.add(solrInputDocument);

任何幫助將得到高度讚賞。

回答

0

您還可以使用

例如如果您正在使用solr4.7.2這些罐子存在於文件夾solr4.7.2 \ DIST \ solrj-LIB \

+0

而對於上面的你可以找到依賴於solrj的nesessary jar – Veeresh123