Problem with HttpSolrClient.Builder on Windows with tomcat
Hello I have problem with HttpSolrClient.Builder on Windows with tomcat I have follwing code lines in my programm: System.out.println("Trying HttpSolrClient = " + url ); LibraryServlet.solrClientClient = new HttpSolrClient.Builder(url).withConnectionTimeout(5000).withSocketTimeout(3000).build(); System.out.println("Trying HttpSolrClient sucessfull "); and project WEB-INF/lib contains following jars: commons-codec-1.15.jar* commons-httpclient-3.1.jar* commons-io-1.4.jar* httpclient5-5.0.3.jar slf4j-api-1.8.0-beta4.jar slf4j-log4j12.jar* solr-solrj-8.6.3.jar* On Ubuntu I have following tomcat output Trying HttpSolrClient = http://localhost:8983/solr/clients SLF4J: No SLF4J providers were found. SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details. SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions prior to 1.8. SLF4J: Ignoring binding found at [jar:file:/home/hydra/Librarian/target/Librarian/WEB-INF/lib/slf4j-log4j12.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Ignoring binding found at [jar:file:/opt/tomcat/apache-tomcat-9.0.38/lib/nlog4j-1.2.19.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Ignoring binding found at [jar:file:/opt/tomcat/apache-tomcat-9.0.38/lib/logback-classic-1.1.3.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#ignoredBindings for an explanation. Trying HttpSolrClient sucessfull But on Windows tomcat I have only one line: Trying HttpSolrClient = http://localhost:8983/solr/clients and it's hangs !!! What is the reason ? Regards Raivo
Re: HttpSolrClient.Builder
On 10/18/2016 2:39 PM, wmcgin...@cox.net wrote: > What causes this? > Exception in thread "main" java.lang.NoClassDefFoundError: > org/apache/http/impl/client/CloseableHttpClient > at > org.apache.solr.client.solrj.impl.HttpSolrClient.(HttpSolrClient.java:209) > at > org.apache.solr.client.solrj.impl.HttpSolrClient$Builder.build(HttpSolrClient.java:874) This is most likely caused by having multiple versions of jars on your classpath. You've probably got an older version of the HttpComponents jars (httpclient, httpmime, httpcore) somewhere that's missing a class that SolrJ needs from the newer version. The correct jar versions can be found included with Solr. > The code is: > return new HttpSolrClient.Builder(urlString).build(); > After connecting to a Solr server, should I call solrServer.close(); > or > should I leave the connection open until the entire index is built? The intent is that the client object will be created once and used in the program until it stops running. Many users *never* close the client. It can also be shared by multiple threads with no problems. Thanks, Shawn
HttpSolrClient.Builder
What causes this? Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/impl/client/CloseableHttpClient at org.apache.solr.client.solrj.impl.HttpSolrClient.(HttpSolrClient.java:209) at org.apache.solr.client.solrj.impl.HttpSolrClient$Builder.build(HttpSolrClient.java:874) The code is: return new HttpSolrClient.Builder(urlString).build(); After connecting to a Solr server, should I call solrServer.close(); or should I leave the connection open until the entire index is built?