Hi, Yes, Andy has the right idea. If no zk-chroot is being used, "Optional.empty()" is the correct value to specify, not null.
This API is a bit trappy (or at least unintuitive), and we're in the process of hashing out some doc improvements (and/or API changes). If you're curious or would otherwise like to weigh in, check out SOLR-12309. Best, Jason On Mon, Jun 18, 2018 at 1:09 PM, Andy C <andycs...@gmail.com> wrote: > I am using the following (Solr 7.3.1) successfully: > > import java.util.Optional; > > Optional<String> chrootOption = null; > if (StringUtils.isNotBlank(_zkChroot)) > { > chrootOption = Optional.of(_zkChroot); > } > else > { > chrootOption = Optional.empty(); > } > CloudSolrClient client = new CloudSolrClient.Builder(_zkHostList, > chrootOption).build(); > > Adapted from code I found somewhere (unit test?). Intent is to support the > option of configuring a chroot or not (stored in "_zkChroot") > > - Andy - > > On Mon, Jun 18, 2018 at 12:53 PM, THADC <timothy.clotworthy.j...@gmail.com > > > wrote: > > > Hello, > > > > I am using solr 7.3 and zookeeper 3.4.10. I have custom client code that > is > > supposed to connect the a zookeeper cluster. For the sake of clarity, the > > main code focus: > > > > > > private synchronized void initSolrClient() > > { > > List<String> zookeeperList = new ArrayList<String>(); > > > > zookeeperList.add("http://100.12.119.10:2281"); > > zookeeperList.add("http://100.12.119.10:2282"); > > zookeeperList.add("http://100.12.119.10:2283"); > > > > String collectionName = "myCollection" > > > > log.debug("in initSolrClient(), collectionName: " + > > collectionName); > > > > try { > > solrClient = new CloudSolrClient.Builder( > zookeeperList, > > null).build(); > > > > } catch (Exception e) { > > log.info("Exception creating solr client object. > > "); > > e.printStackTrace(); > > } > > solrClient.setDefaultCollection(collectionName); > > } > > > > Before executing, I test that all three zoo nodes are running > > (./bin/zkServer.sh status zoo.cfg, ./bin/zkServer.sh status zoo2.cfg, > > ./bin/zkServer.sh status zoo3.cfg). The status shows the quorum is > > up and running, with one nodes as the leader and the other two as > > followers. > > > > When I execute my java client to connect to the zookeeper cluster, I get > : > > > > java.lang.NullPointerException > > at > > org.apache.solr.client.solrj.impl.CloudSolrClient$Builder.< > > init>(CloudSolrClient.java:1387) > > > > > > I am assuming it has a problem with my null value for zkChroot, but not > > certain. Th API says zkChroot is the path to the root ZooKeeper node > > containing Solr data. May be empty if Solr-data is located at the > ZooKeeper > > root. > > > > I am confused on what exactly should go here, and when it can be null. I > > cannot find any coding examples. > > > > Any help greatly appreciated. > > > > > > > > > > -- > > Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html > > >