Support Questions
Find answers, ask questions, and share your expertise

SolrJ : Can create new Solr Collections successfully, but cannot query them (giving 403 error) ?


We have a Kerberised HDP(2.6.4) Cluster.I am trying to connect to Infra-Solr using SolrJ client.

All the krb5.conf,keytabs,Jaas.conf ..etc are configured fine and I can create new Collections using Solrj4 client.

However I cannot query the these newly created Collections using the same user. Giving the error:

org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at Expected mime type application/octet-stream but got text/html. <html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Error 403 Unauthorized request, Response code: 403</title>
<body><h2>HTTP ERROR 403</h2>
<p>Problem accessing /solr/TempCollection3/select. Reason:
<pre>    Unauthorized request, Response code: 403</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>

My code snippet is as follows :

public void run() throws Exception {
    SolrClient client =  getClient(); //getCloudClient()

    String collection = "TempCollection3";
    String mQuery="*:*";
    SolrQuery q = new SolrQuery();

    ConfigSetAdminRequest.List lst=new ConfigSetAdminRequest.List();
        System.out.println (">>>>>>>>>>> Config Sets >>>>>>>>>>>  "+lst.process(client));

    boolean collectionFound = false;
    try {
    System.out.println(">>>>>>>>> Querying collection >>>>>"+collection);
    QueryResponse res = client.query(collection, q);
    collectionFound = true;
    } catch (Exception e) {
    //catch proper Exception and check for 404
    if (!collectionFound) {
    System.out.println(">>>>>>>>> Creating Collection >>>>>>>> "+collection);
    CollectionAdminRequest.createCollection(collection, "default", 1, 1).process(client);
    } else {
    System.out.println(">>>>>>>>> Collection "+collection+ " already exists >>>>>>>>>");
    System.out.println(">>> Closing Client");


First time it runs and creates a new Collection "TempCollection3". However the second time it runs, the call "client.query(collection, q);" fails giving 403.

Any tips on what I could be doing wrong ? (I have the user "infra-slor" in Ranger permissions as well)


Also CAN index documents in these new Collections using :

SolrInputDocument document = new SolrInputDocument(); 
document.addField("id", "552199"); 
UpdateResponse response =client.add(collection, document);