'Unable to obtain password from user kerberos error using Spring JPA

I am trying to use Spring JPA to connect to mssql db using kerberos. I generated keytab using:

ktab -k <keytabPath> -a <name>@<domain>

created jaas.conf file:

SQLJDBCDriver {
    com.sun.security.auth.module.Krb5LoginModule
    required
    client=TRUE
    doNotPrompt=true
    debug=true
    useKeyTab=true
    storeKey=true
    keyTab="<keytabName>" 
    principal="<name>@<domain>"
};

both keyTab and jaas.conf files are in resource folder

app.properties:

spring.jpa.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
spring.jpa.hibernate.ddl-auto=none
spring.jpa.hibernate.show_sql=true
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.datasource.url=jdbc:<url>\\<instance>:<port>;databaseName=<dbName>;authenticationScheme=JavaKerberos;integratedSecurity=true;domain=<domain>

set the VM parameters:

-Djavax.net.ssl.trustStore=<path_to_cacerts>
-Djava.security.krb5.conf=<path_to_krb5>
-Djava.security.auth.login.config=<path_to_jaas>
-Duser.name=<name>
-Djavax.security.auth.useSubjectCredsOnly=true
-Djava.security.krb5.realm=<domain>
-Djava.security.krb5.kdc=<domain>
-Dsun.security.krb5.debug=true
-Djavax.net.debug=ssl

yet i am getting: Unable to obtain password from user error. What is wrong ? It seems the set up is correct. I can connect to the database using intellij database window ( using windows credential option ).



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source