title: GSSException: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt)
body: <p>I am very much new to the MOngoDB + Java Configuration. I am trying to achive the connection from remote mongodb server from Java application. I want to use GSSAPI mechanism for connection with mongotemplate. Below code has been executing successfully. Below code is from my configuration file.</p>
  
  <pre><code>List&lt;ServerAddress&gt; serverAddresses = new ArrayList&lt;ServerAddress&gt;();
      ServerAddress address = new ServerAddress(host, port);
      serverAddresses.add(address);
      List&lt;MongoCredential&gt; credentials = new ArrayList&lt;MongoCredential&gt;();
  
      MongoCredential credential = MongoCredential.createGSSAPICredential(userName);
  
      credential.withMechanismProperty("SERVICE_NAME", gssapiServiceName);
      credential.withMechanismProperty("CANONICALIZE_HOST_NAME", true);
      credentials.add(credential);
  
      return new MongoClient(serverAddresses, credentials);
  </code></pre>
  
  <p>But when I am trying execute below code I am getting exception</p>
  
  <pre><code>DB db = mongoTemplate.getDb();
  Set&lt;String&gt; dbCollections1 = db.getCollectionNames();
  </code></pre>
  
  <p>Exception:</p>
  
  <blockquote>
    <p>GSSException: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt)
        at sun.security.jgss.krb5.Krb5InitCredential.getInstance(Krb5InitCredential.java:147)
        at sun.security.jgss.krb5.Krb5MechFactory.getCredentialElement(Krb5MechFactory.java:122)
        at sun.security.jgss.GSSManagerImpl.getCredentialElement(GSSManagerImpl.java:193)
        at sun.security.jgss.GSSCredentialImpl.add(GSSCredentialImpl.java:427)
        at sun.security.jgss.GSSCredentialImpl.(GSSCredentialImpl.java:62)
        at sun.security.jgss.GSSManagerImpl.createCredential(GSSManagerImpl.java:154)
        at com.mongodb.DBPort$GSSAPIAuthenticator.getGSSCredential(DBPort.java:622)
        at com.mongodb.DBPort$GSSAPIAuthenticator.createSaslClient(DBPort.java:593)
        at com.mongodb.DBPort$SaslAuthenticator.authenticate(DBPort.java:895)
        at com.mongodb.DBPort.authenticate(DBPort.java:432)
        at com.mongodb.DBPort.checkAuth(DBPort.java:443)
        at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:289)
        at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:269)
        at com.mongodb.DBCollectionImpl.find(DBCollectionImpl.java:84)
        at com.mongodb.DB.command(DB.java:320)
        at com.mongodb.DB.command(DB.java:299)
        at com.mongodb.DB.command(DB.java:388)
        at com.mongodb.DBApiLayer.getCollectionNames(DBApiLayer.java:152)</p>
  </blockquote>