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");

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(
3 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
4 at sun.reflect.NativeMethodAccessorImpl.invoke(
5 at sun.reflect.DelegatingMethodAccessorImpl.invoke(
6 at java.lang.reflect.Method.invoke(
7 at com.intellij.rt.execution.application.AppMain.main(