title: How to configure Spring data SolrCloud connection with Basic Authentication
body: <p>I have configure Solr 6.2.1 as SolrCloud. Later I have Configured Basic Authentication.
  I am going to configure Spring data solr 2.0.4.RELEASE with Solrj 6.2 and this is my code:</p>
  
  <pre><code>@Configuration
  @EnableSolrRepositories(basePackages = { "ir.saeed.server.solr" }, multicoreSupport = true)
  
  public class SearchContext {
  
      @Value("${solr.host}")
  
      private String host;
  
  
      @Value("${solr.port}")
  
      private Integer port;
  
  
      @Value("${solr.username}")
  
      private String username;
  
  
      @Value("${solr.password}")
  
      private String password;
  
  
      @Value("${zkHost}")
  
      private String zkHost;
  
  
      @Value("${solr.coreName}")
  
      private String collectionName;
  
  
      @Bean
  
      public SolrTemplate solrTemplate() {
  
          return new SolrTemplate(solrClientFactory());
  
      }
  
  
      @Bean
  
      public BasicCredentialsProvider credentialsProvider() {
  
          BasicCredentialsProvider provider = new BasicCredentialsProvider();
  
          provider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
  
          return provider;
  
      }
  
  
      @Bean
  
      public SolrClientFactory solrClientFactory() {
  
          return new HttpSolrClientFactory(solrClient(), "", credentialsProvider().getCredentials(AuthScope.ANY), "BASIC");
  
      }
  
  
      @Bean
  
      public SolrClient solrClient() {
  
          return new CloudSolrClient.Builder().withZkHost(zkHost).build();
  
      }
  
  }
  </code></pre>
  
  <p>But when i run my web application this Exception occures:</p>
  
  <pre><code> 10:51:48,110 org.springframework.data.solr.UncategorizedSolrException: nested exception is java.lang.NullPointerException
  
  
   10:51:48,111   at org.springframework.data.solr.core.SolrTemplate.execute(SolrTemplate.java:172)
  
  
   10:51:48,111   at org.springframework.data.solr.core.SolrTemplate.executeSolrQuery(SolrTemplate.java:509)
  
  
   10:51:48,111   at org.springframework.data.solr.core.SolrTemplate.query(SolrTemplate.java:504)
  
  
   10:51:48,111   at org.springframework.data.solr.core.SolrTemplate.doQueryForPage(SolrTemplate.java:338)
  
  
   10:51:48,111   at org.springframework.data.solr.core.SolrTemplate.queryForPage(SolrTemplate.java:350)
  </code></pre>
  
  <p>How can I resolve the issue?
  I think my Configuration is incorrect</p>