Přeskočit na hlavní obsah

Příspěvky

Zobrazují se příspěvky z září, 2015

Solution to failing Configuration.getConfiguration() in Java

Sometimes the calling javax.security.auth.login.Configuration.getConfiguration() fails with SecurityException in our tests (both Oracle and IBM).

A quick solution (without touching JDK installation or configuring java.security.auth.login.config system property) is simple. Just create an empty file .java.login.config in your user home directory (more info in ConfigFile JavaDoc). Thats it!

touch ~/.java.login.config
Just to make the picture complete, here is the stack trace we see on IBM JDK:

Exception in thread "main" java.lang.SecurityException: Unable to locate a login configuration at com.ibm.security.auth.login.ConfigFile.<init>(ConfigFile.java:125) at java.lang.J9VMInternals.newInstanceImpl(Native Method) at java.lang.Class.newInstance(Class.java:1681) at javax.security.auth.login.Configuration$2.run(Configuration.java:263) at javax.security.auth.login.Configuration$2.run(Configuration.java:255) at java.security.AccessController.doPrivileged(AccessController.j…