Null Pointer Exception from UnmarshallerFactory while migrating from OpenSAML2.x to OpenSAML3.x

Brent Putman putmanb at georgetown.edu
Wed Aug 7 18:50:47 EDT 2019


On 8/6/19 1:30 AM, DD K wrote:
>
> The exception is thrown from the code snippet at the commented line:
>
> public static XMLObject unmarshall(String authReqStr) throws IdentityException {
>     InputStream inputStream = null; try {
>         doBootstrap(); DocumentBuilderFactory documentBuilderFactory = IdentityUtil.getSecuredDocumentBuilderFactory(); DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder(); inputStream = new ByteArrayInputStream(authReqStr.trim().getBytes(StandardCharsets.UTF_8)); Document document = docBuilder.parse(inputStream); Element element = document.getDocumentElement(); UnmarshallerFactory unmarshallerFactory = XMLObjectProviderRegistrySupport.getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element);return unmarshaller.unmarshall(element); // Exception thrown here } catch (Exception e) {
>         log.error("Error in constructing AuthRequest from the encoded String", e); throw IdentityException.error(
>                 "Error in constructing AuthRequest from the encoded String ", e); } finally {
>         if (inputStream != null) {
>             try {
>                 inputStream.close(); } catch (IOException e) {
>                 log.error("Error while closing the stream", e); }
>         }
>     }
> }
>


I don't see anything obviously wrong there.  If it's throwing on that
line, it's likely that the unmarshaller is null, which means you didn't
get anything back from the unmarshallerFactory.  That means something
is likely not working with your initialization of the library.  I can't
say anything more than that.  I'd suggest turning up logging to DEBUG
or even TRACE on some or all of the OpenSAML packages to see what is
actually happening, for example whether you are actually successfully
reading and registering the XMLObject builders, marshallers and
unmarshallers.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/dev/attachments/20190807/c360b723/attachment.html>


More information about the dev mailing list