3

I have recently upgraded opensaml dependency from 2.5.3 to 2.6.1 and xmlutil from 1.3.0 to 1.4.1. It compiles without any errors but while running the application i get the following exception:

java.lang.NullPointerException
org.opensaml.xml.io.AbstractXMLObjectMarshaller.marshall(AbstractXMLObjectMarshaller.java:84)

Calling Code:

final MarshallerFactory marshallerFac = SAMLUtil.getMarshallerFactory();
     final org.opensaml.xml.io.Marshaller authnStatementMarshaller = marshallerFac.getMarshaller(assertion);

     Element assertionElement = null;

     try {
        assertionElement = authnStatementMarshaller.marshall(assertion);
        try {
           // Sign assertion and query signature
           Signer.signObject(signature);
        }
        catch (final SignatureException e) {
           LOGGER.error("Fout opgetreden bij ondertekenen Assertion", e);
        }
     }
avinash chavan
  • 729
  • 2
  • 11
  • 27

1 Answers1

6

I've noticed that if you don't initialize ("bootstrap") the SAML configuration, you get a NullPointerException (rather unhelpfully, I might add) when you try to construct the SAML.

import org.opensaml.DefaultBootstrap;
import org.opensaml.xml.ConfigurationException;

try {
    DefaultBootstrap.bootstrap();
}
catch (ConfigurationException ce) {
}

The above is just a snippet of code to illustrate what I'm talking about. Did you maybe forget to bootstrap the configuration? That has to be done before you do anything.

Mario
  • 2,397
  • 2
  • 24
  • 41
  • it worked. But could you tell me what the DefaultBootstrap.bootstrap(); exactly does? and was this introduced after 2.5.3 version of opensaml? or 1.3.0 of xmltooling? Thanks. – avinash chavan Dec 31 '14 at 06:20
  • I honestly don't know the details of what it does. I guess we'd have to look into the source files for OpenSAML. I never used SAML before September; all I know is that somewhere along the line I learned that you have to call the method. What bothers me is that the NullPointerException is an API copout. There really should be a more descriptive error. Would it have killed them to have created a SAMLConfigurationException and have that thrown somewhere along the lines? Anyway, glad to have helped! – Mario Jan 01 '15 at 15:49
  • The source for the DefaultBootstrap class can be found at the URL below. That may give a hint as to what the bootstrap method does. http://grepcode.com/file/repo1.maven.org/maven2/org.opensaml/opensaml/2.4.1/org/opensaml/DefaultBootstrap.java – Mario Feb 18 '15 at 22:07