NullPointerException at com.google.common.collect.Iterables.getOnlyElement() when logging in with SAML SSO

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

After configuring SAML SSO as described in SAML single sign-on for Atlassian Data Center applications, users are unable to log in via SSO with the message Sorry, we had some technical problems during your last operation.

Environment

Jira Data Center using the bundled SSO for Atlassian Data Center app.

Diagnosis

The following error is observed in the Jira logs:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2024-04-15 03:42:27,684+0000 http-nio-8080-exec-28 url: /plugins/servlet/samlconsumer ERROR anonymous 222x118761x1 ounita 10.130.33.237,10.20.200.12 /plugins/servlet/samlconsumer [o.a.c.c.C.[Catalina].[localhost].[/]] Unhandled exception occurred whilst decorating page java.lang.NullPointerException at com.google.common.collect.Iterables.getOnlyElement(Iterables.java:263) at com.atlassian.plugins.authentication.impl.web.saml.SamlConsumerServlet.getAttributeOrNameId(SamlConsumerServlet.java:176) at com.atlassian.plugins.authentication.impl.web.saml.SamlConsumerServlet.lambda$getUsername$7(SamlConsumerServlet.java:172) at java.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:178) at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) at com.atlassian.plugins.authentication.impl.web.usercontext.impl.jit.mapping.MappingExpression.evaluateWithValues(MappingExpression.java:97) at com.atlassian.plugins.authentication.impl.web.saml.SamlConsumerServlet.getUsername(SamlConsumerServlet.java:172) at com.atlassian.plugins.authentication.impl.web.saml.SamlConsumerServlet.doPost(SamlConsumerServlet.java:102)

Cause

The most common cause of this error is when the Username mapping setting has been incorrectly set when configuring SAML SSO in Jira. This causes Jira to be unable to retrieve the username attribute; the missing attribute then causes a NullPointerException.

Solution

Check with your SSO provider to confirm which SAML attribute contains the username, and change the Username mapping setting to the correct value.

Updated on March 12, 2025

Still need help?

The Atlassian Community is here for you.