Hi,

I have just set up the Basic Authentication Plugin in Solr 6.4.2 on
SolrCloud, and I am trying to modify my SolrJ code so that the code can go
through the authentication and do the indexing.

I tried using the following code from the Solr Documentation
https://cwiki.apache.org/confluence/display/solr/Basic+Authentication+Plugin
.

SolrRequest req ;//create a new request object
req.setBasicAuthCredentials(userName, password);
solrClient.request(req);

However, the code complains that the req is not initialized.

If I initialized it, it will be initialize as null.

SolrRequest req = null;//create a new request object
req.setBasicAuthCredentials(userName, password);
solrClient.request(req);

This will caused a null pointer exception.
Exception in thread "main" java.lang.NullPointerException

How should we go about putting these codes, so that the error can be
prevented?

Regards,
Edwin

Reply via email to