Java.lang.NoClassDefFoundError: org/noggit/CharArr while adding document to be indexed in solr

javasolrsolrj

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.

Best Solution

I think you have not included the noggit-0.5.jar file in you program

Download it from http://www.java2s.com/Code/Jar/n/Downloadnoggit05jar.htm

or Maven-Repository

and then import it in your project library.

Related Question