Monday, May 5, 2014

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 mot uses. Before starting the use the library the configurations must be loaded. This is done using the bootstrap function.

try {
} catch (ConfigurationException e) {
   throw new RuntimeException("Bootstrapping failed");

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

Exception in thread "main" java.lang.NullPointerException
 at no.steras.opensaml.Main.main(
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(
 at java.lang.reflect.Method.invoke(
 at com.intellij.rt.execution.application.AppMain.main(


  1. What to do if DefaultBootstrap gives an InputStream cannot be null?
    Exception in thread "main" java.lang.IllegalArgumentException: InputStream cannot be null
    at javax.xml.parsers.DocumentBuilder.parse(
    at org.opensaml.xml.parse.BasicParserPool$DocumentBuilderProxy.parse(
    at org.opensaml.xml.parse.BasicParserPool.parse(
    at org.opensaml.xml.XMLConfigurator.load(
    at org.opensaml.DefaultBootstrap.initializeXMLTooling(
    at org.opensaml.DefaultBootstrap.bootstrap(
    at com.ccs.saml.metadata.SamlMetadataGenerator.main(

    Do I need to put a config-file somewhere specific?
    If so, which file and where should I put it?

    1. Try this

  2. Thanks, after adding openws.jar and creating a good X509 certificate, I now got it working.