Erik,

Thank you so much!

On Sat, Mar 17, 2018 at 5:50 PM, Erick Erickson <erickerick...@gmail.com>
wrote:

> So if you're saying that the docs are successfully added, then you can
> ignore the SLF4J messages. They're just telling you that you don't have
> logging configured. If your client application wants to use a logging
> framework you have to do additional work.
>
> Solr (and SolrJ) allow you to use whatever SLF4J-compliant implementation
> you want for logging, but you must configure it. The referenced link will
> give
> you a start.
>
> But for test programs it's not _necessary_....
>
> Best,
> Erick
>
>
> On Fri, Mar 16, 2018 at 2:02 PM, Andy Tang <andytang2...@gmail.com> wrote:
> > Erik,
> >
> > Thank you for reminding.
> > javac -cp
> > .:/opt/solr/solr-6.6.2/dist/*:/opt/solr/solr-6.6.2/dist/solrj-lib/*
> >  AddingDocument.java
> >
> > java -cp
> > .:/opt/solr/solr-6.6.2/dist/*:/opt/solr/solr-6.6.2/dist/solrj-lib/*
> >  AddingDocument
> >
> > SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
> > SLF4J: Defaulting to no-operation (NOP) logger implementation
> > SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for
> further
> > details.
> > Documents added
> >
> > All jars are included and documents added successfully. However, there
> are
> > some error message coming out.
> >
> > Thank you.
> >
> >
> > On Fri, Mar 16, 2018 at 12:43 PM, Erick Erickson <
> erickerick...@gmail.com>
> > wrote:
> >
> >> this is the important bit:
> >>
> >> java.lang.NoClassDefFoundError: org/apache/http/Header
> >>
> >> That class is not defined in the Solr code at all, it's in
> >> httpcore-#.#.#.jar
> >>
> >> You probably need to include /opt/solr/solr-6.6.2/dist/solrj-lib in
> >> your classpath.
> >>
> >> Best,
> >> Erick
> >>
> >> On Fri, Mar 16, 2018 at 12:14 PM, Andy Tang <andytang2...@gmail.com>
> >> wrote:
> >> > I have the code to add document to Solr. I tested it in Both Solr
> 6.6.2
> >> and
> >> > Solr 7.2.1 and failed.
> >> >
> >> > import java.io.IOException;  import
> >> > org.apache.solr.client.solrj.SolrClient; import
> >> > org.apache.solr.client.solrj.SolrServerException; import
> >> > org.apache.solr.client.solrj.impl.HttpSolrClient; import
> >> > org.apache.solr.common.SolrInputDocument;
> >> > public class AddingDocument {
> >> >    public static void main(String args[]) throws Exception {
> >> >
> >> > String urlString ="http://localhost:8983/solr/Solr_example";;
> >> >      SolrClient Solr = new HttpSolrClient.Builder(urlString).build();
> >> >
> >> >       //Preparing the Solr document
> >> >       SolrInputDocument doc = new SolrInputDocument();
> >> >
> >> >       //Adding fields to the document
> >> >       doc.addField("id", "007");
> >> >       doc.addField("name", "James Bond");
> >> >       doc.addField("age","45");
> >> >       doc.addField("addr","England");
> >> >
> >> >       //Adding the document to Solr
> >> >       Solr.add(doc);
> >> >
> >> >       //Saving the changes
> >> >       Solr.commit();
> >> >       System.out.println("Documents added");
> >> >    } }
> >> >
> >> > The compilation is successful like below.
> >> >
> >> > javac -cp .:/opt/solr/solr-6.6.2/dist/solr-solrj-6.6.2.jar
> >> > AddingDocument.java
> >> >
> >> > However, when I run it, it gave me some errors message confused.
> >> >
> >> > java -cp .:/opt/solr/solr-6.6.2/dist/solr-solrj-6.6.2.jar
> AddingDocument
> >> >
> >> > Exception in thread "main" java.lang.NoClassDefFoundError:
> >> > org/apache/http/Header
> >> >     at org.apache.solr.client.solrj.impl.HttpSolrClient$Builder.
> >> build(HttpSolrClient.java:892)
> >> >     at AddingDocument.main(AddingDocument.java:13)Caused by:
> >> > java.lang.ClassNotFoundException: org.apache.http.Header
> >> >     at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
> >> >     at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> >> >     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
> >> >     at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> >> >     ... 2 more
> >> >
> >> > What is wrong with it? Is this urlString correct?
> >> >
> >> > Any help is appreciated!
> >> > Andy Tang
> >>
>

Reply via email to