NullPointerException when viewing User Profile

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

  1. When viewing a user profile, a NullPointerException is generated.
  2. When attempting to view an avatar, the same exception is generated.

The following appears in the atlassian-jira.log:

2012-09-19 16:18:12,258 http-8080-5 ERROR captain.planet 978x1081x1 1unn6n4 10.166.1.14 /secure/ViewProfile.jspa [com.atlassian.velocity.DefaultVelocityManager] MethodInvocationException occurred getting message body from Velocity: java.lang.NullPointerException
java.lang.NullPointerException
	at com.opensymphony.module.propertyset.ofbiz.OFBizPropertySet.getKeys(OFBizPropertySet.java:145)
	at com.opensymphony.module.propertyset.AbstractPropertySet.getKeys(AbstractPropertySet.java:231)
	at com.atlassian.jira.propertyset.JiraCachingPropertySet.getKeys(JiraCachingPropertySet.java:377)
	at com.atlassian.jira.user.profile.DetailsUserProfileFragment.getUserProperties(DetailsUserProfileFragment.java:203)
	at com.atlassian.jira.user.profile.DetailsUserProfileFragment.createVelocityParams(DetailsUserProfileFragment.java:135)
	at com.atlassian.jira.user.profile.AbstractUserProfileFragment.getFragmentHtml(AbstractUserProfileFragment.java:65)
	at sun.reflect.GeneratedMethodAccessor856.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:381)
	at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:370)
	at com.atlassian.velocity.htmlsafe.introspection.AnnotationBoxingMethod.invoke(AnnotationBoxingMethod.java:26)
	at com.atlassian.velocity.htmlsafe.introspection.UnboxingMethod.invoke(UnboxingMethod.java:30)
	at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:270)
	at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:262)
	at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:342)
	at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72)
	at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:87)
	at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:336)
	at org.apache.velocity.Template.merge(Template.java:328)
	at org.apache.velocity.Template.merge(Template.java:235)
    ...

Cause

An error has caused an update of the user properties to be half-complete, leaving a null in the place of where an object should be.

Resolution

Always back up your data before performing any modification to the database. If possible, try your modifications on a test server.

  1. Using the Database Integrity Checker, verify if this fixes the problem. If not, continue with the following steps.
  2. Stop JIRA.
  3. Identify the NULL values within the propertyentry table with the following SQL:

    SELECT * FROM propertyentry p JOIN external_entities e ON p.entity_id = e.id WHERE p.id IS NULL OR entity_name IS NULL OR entity_id IS NULL OR property_key IS NULL OR propertytype IS NULL;

    In this example, the below was returned:

    22359	ExternalEntity	10	jira.user.suppressedTips.focusShifter	NULL	10	captain.planet	com.atlassian.jira.user.OfbizExternalEntityStore
    tip/resting Created with Sketch.

    In order to correct this fix, manipulation of the database will be required. If incorrect updates are made, it can cause data integrity issues, so do so at your own risk. If you're uncertain what to do, please contact Atlassian Support at support.atlassian.com.

  4. After identifying the record within the database, it will need to be updated with an appropriate value. To identify what the value could be, it is necessary to compare it to other records that are working. In this example, this propertyentry.property_key has the NULL. To identify other values in the database, the following SQL can be used. If need be, replace jira.user.suppressedTips.focusShifter with the value that has the NULL.

     SELECT * FROM propertyentry p JOIN external_entities e ON p.entity_id = e.id WHERE property_key = 'jira.user.suppressedTips.focusShifter';

    Which in this example has returned the below results:

    22359	ExternalEntity	10	jira.user.suppressedTips.focusShifter	NULL	10	captain.planet	com.atlassian.jira.user.OfbizExternalEntityStore
    22559	ExternalEntity	910	jira.user.suppressedTips.focusShifter	NULL	910	wonder.woman	com.atlassian.jira.user.OfbizExternalEntityStore
  5. As can be seen from these results, propertyentry.propertytype of 1 for user wonder.woman is a valid value (provided that user is not experiencing any errors!) and the database can be updated to reflect the value, as below:

     UPDATE propertyentry SET propertytype = 1 where id = {ID from the problematic record};
  6. Start JIRA.
  7. Test if the user works by replicating the behaviour. If the problem is still present, please restore your backup immediately and raise a Support Request on support.atlassian.com

Alternative

It's also possible to remove the avatar entries directly from the database using the following SQL, however this may not necessarily be the cause. Replace captain.planet with the user name that requires correcting.

DELETE 	pn, pe, a

FROM 	external_entities e

JOIN 	propertyentry pe
ON 		e.id 		= 		pe.entity_id
JOIN 	propertynumber pn
ON 		pe.id 		=		pn.id
JOIN 	avatar a
ON 		a.id 		= 		pn.propertyvalue

WHERE	name		=		'captain.planet';
tip/resting Created with Sketch.

The above is MySQL syntax and may need changing for Oracle or MS SQL. If multiple users require updating, the operator used in the WHERE clause could be replaced with an IN.

Last modified on Nov 12, 2018

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.