diff --git a/src/main/java/org/apache/commons/crypto/random/CryptoRandomFactory.java b/src/main/java/org/apache/commons/crypto/random/CryptoRandomFactory.java index 8acdf9c8d..1b5f8ae07 100644 --- a/src/main/java/org/apache/commons/crypto/random/CryptoRandomFactory.java +++ b/src/main/java/org/apache/commons/crypto/random/CryptoRandomFactory.java @@ -198,6 +198,14 @@ public static CryptoRandom getCryptoRandom(final Properties props) } catch (final Exception e) { lastException = e; errorMessage.append("CryptoRandom: [" + className + "] failed with " + e.getMessage()); + } catch (final ExceptionInInitializerError initializerError) { + Throwable t = initializerError.getException(); + if (t isinstanceof Exception) { + lastException = (Exception) t; + errorMessage.append("CryptoRandom: [" + className + "] initialization failed with " + t.getMessage()); + } else { + throw initializerError; + } } }