ePrivacy and GPDR Cookie Consent by Cookie Consent

Nullpointer exception in OpenSAML

This is a common exception to beginners in using OpenSAML. A common mistake when starting to use the OpenSAML library is to not initialise the library. OpenSAML needs a couple of configuration files in order to work. The library is provided with a default set of these files that is sufficient for most uses. Before starting the use the library the configurations must be loaded. This is done using the bootstrap function.

1try {
2   DefaultBootstrap.bootstrap();
3} catch (ConfigurationException e) {
4   throw new RuntimeException("Bootstrapping failed");
5}     

If you do not do this before you start using the library, you might run into exceptions like.

1Exception in thread "main" java.lang.NullPointerException
2 at no.steras.opensaml.Main.main(Main.java:25)
3 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
4 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
5 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
6 at java.lang.reflect.Method.invoke(Method.java:601)
7 at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)