Error: Java GSS-API with SPNEGO: Server not found in Kerberos database (7)
<p>I'm trying to get this tutorial to work: <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/security/jgss/lab/part5.html" rel="nofollow">https://docs.oracle.com/javase/8/docs/technotes/guides/security/jgss/lab/part5.html</a></p>

<p>I'm running a Kerberos KDC on a VM and used this guide for setting it up: <a href="http://techpubs.spinlocksolutions.com/dklar/kerberos.html" rel="nofollow">http://techpubs.spinlocksolutions.com/dklar/kerberos.html</a></p>

<p>I have set up two princripals: jessica@REALM.COM and host/jessica-ThinkPad-X220@REALM.COM and the key for the 2nd one is saved in a keytab which I copied from the VM to my test machine.</p>

<p>I can ping the KDC and get tickets with <code>kinit</code>.</p>

<p>I compiled all code examples (<code>Jaas.java</code> <code>GssSpNegoServer.java</code> and <code>GssSpNegoClient.java</code>) without changes from the tutorial.</p>

<p>This is my <code>jaas-krb5.conf</code>:</p>

<pre><code>client {
com.sun.security.auth.module.Krb5LoginModule required
principal="jessica";
};

server {
com.sun.security.auth.module.Krb5LoginModule required
useKeyTab=true
storeKey=true
keyTab=krb5.keytab
principal="host/jessica-ThinkPad-X220";
};
</code></pre>

<p>I am starting the server with <code>java -Djava.security.auth.login.config=jaas-krb5.conf GssSpNegoServer</code></p>

<p>Then, in another window, I am starting the client with 
<code>java -Djava.security.auth.login.config=jaas-krb5.conf GssSpNegoClient host hostname</code> which gives me the following error:</p>

<pre><code>$ java -Djava.security.auth.login.config=jaas-krb5.conf GssSpNegoClient host jessica-ThinkPad-X220
Kerberos-Password for jessica: 
Authenticated principal: [jessica@REALM.COM]
Connected to address jessica-ThinkPad-X220/192.168.178.78
Exception in thread "main" java.security.PrivilegedActionException: GSSException: No valid credentials provided (Mechanism level: No valid  credentials provided (Mechanism level: Server not found in Kerberos database (7) - LOOKING_UP_SERVER))
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at Jaas.loginAndAction(Jaas.java:53)
at GssSpNegoClient.main(GssSpNegoClient.java:56)
Caused by: GSSException: No valid credentials provided (Mechanism level: No valid credentials provided (Mechanism level: Server not found in Kerberos database (7) - LOOKING_UP_SERVER))
at sun.security.jgss.spnego.SpNegoContext.initSecContext(SpNegoContext.java:454)
at sun.security.jgss.GSSContextImpl.initSecContext(GSSContextImpl.java:248)
at sun.security.jgss.GSSContextImpl.initSecContext(GSSContextImpl.java:179)
at GssSpNegoClient$GssClientAction.run(GssSpNegoClient.java:129)
... 4 more
Caused by: GSSException: No valid credentials provided (Mechanism level: Server not found in Kerberos database (7) - LOOKING_UP_SERVER)
at sun.security.jgss.krb5.Krb5Context.initSecContext(Krb5Context.java:770)
at sun.security.jgss.GSSContextImpl.initSecContext(GSSContextImpl.java:248)
at sun.security.jgss.GSSContextImpl.initSecContext(GSSContextImpl.java:179)
at sun.security.jgss.spnego.SpNegoContext.GSS_initSecContext(SpNegoContext.java:882)
at sun.security.jgss.spnego.SpNegoContext.initSecContext(SpNegoContext.java:317)
... 7 more
Caused by: KrbException: Server not found in Kerberos database (7) - LOOKING_UP_SERVER
at sun.security.krb5.KrbTgsRep.&lt;init&gt;(KrbTgsRep.java:73)
at sun.security.krb5.KrbTgsReq.getReply(KrbTgsReq.java:259)
at sun.security.krb5.KrbTgsReq.sendAndGetCreds(KrbTgsReq.java:270)
at sun.security.krb5.internal.CredentialsUtil.serviceCreds(CredentialsUtil.java:302)
at sun.security.krb5.internal.CredentialsUtil.acquireServiceCreds(CredentialsUtil.java:120)
at sun.security.krb5.Credentials.acquireServiceCreds(Credentials.java:458)
at sun.security.jgss.krb5.Krb5Context.initSecContext(Krb5Context.java:693)
... 11 more
Caused by: KrbException: Identifier doesn't match expected value (906)
at sun.security.krb5.internal.KDCRep.init(KDCRep.java:140)
at sun.security.krb5.internal.TGSRep.init(TGSRep.java:65)
at sun.security.krb5.internal.TGSRep.&lt;init&gt;(TGSRep.java:60)
at sun.security.krb5.KrbTgsRep.&lt;init&gt;(KrbTgsRep.java:55)
... 17 more
</code></pre>

<p>I don't know what I am doing wrong, can anybody help?</p>