Skip to main content

Querying custom attributes may return NullPointerException with Portal admin user


Technote (troubleshooting)


Problem

Querying custom attributes may return NullPointerException with Portal admin user

Resolving the problem

The public SPI PumaProfile states in the javadoc:

/**
* Returns a map of values based on the given Attribute names. Those values * are stored with the given Principal. Attributes not defined in the Map
* have either not been defined in the Schema or are not set at this User * Object
..
*/
public Map<String, Object> getAttributes(Principal aPrincipal, List<String> aAttributeNames) throws PumaAttributeException, PumaSystemException, PumaModelException, PumaMissingAccessRightsException;

So attributes that are not set for a user (although would be valid to set) will not be part of the result map.
The sample code from navigation.jsp would then fail with a NullPointerException, which can be seen in SystemOut.log

userTiers = map.get("company").toString(); -> map.get("company")
returns null -> null.toString() causes NullPointerException
System.out.println("navigation.jsp::company: " + userTiers);
userInfos[1] = userTiers;

} catch(Exception e){
System.out.println("navigation.jsp::Exception: " + e); ->
NullPointerException is caught and logged
}

The line userTiers = map.get("company").toString() in navigation jsp should be checked to be able to handle null results from the map. Also the exception catching block should be changed to log the full stacktrace to confirm, that the NullPointerException is caused by the navigation.jsp code and not from deeper code layers.

The recommendation is to make navigation.jsp more robust for null values and error handling. Also please check LDAP to see if for the particular use has the particular attribute set.



Rate this page:

(0 users)Average rating

Copyright and trademark information

IBM, the IBM logo and ibm.com are trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at www.ibm.com/legal/copytrade.shtml.

Rate this page:


(0 users)Average rating

Add comments

Document information

WebSphere Portal

Security


Software version:
7.0


Operating system(s):
AIX, Linux, Solaris, Windows


Software edition:
Enable, Express, Extend, Server


Reference #:
1608177


Modified date:
2012-11-19

Translate my page

Content navigation