Lockable Resources Plugin throws null pointer exception

Article ID:360030552792
1 minute readKnowledge base

Issue

The Lockable Resources Plugin throws a null pointer exception. Resources are unable to be locked.

2019-03-22 21:11:20.945+0000 [id=1480]  WARNING o.e.jetty.util.log.JavaUtilLog#warn: Error while serving https://jenkins.example.net/lockable-resources/unlock
java.lang.NullPointerException
    at org.jenkins.plugins.lockableresources.LockableResourcesManager.freeResources(LockableResourcesManager.java:261)
    at org.jenkins.plugins.lockableresources.LockableResourcesManager.unlockNames(LockableResourcesManager.java:300)
    at org.jenkins.plugins.lockableresources.LockableResourcesManager.unlock(LockableResourcesManager.java:285)
    at org.jenkins.plugins.lockableresources.LockableResourcesManager.unlock(LockableResourcesManager.java:273)
    at org.jenkins.plugins.lockableresources.actions.LockableResourcesRootAction.doUnlock(LockableResourcesRootAction.java:103)
    at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)

Resolution

This issue occurs if the org.jenkins.plugins.lockableresources.LockableResourcesManager.xml file contains an entry that does not have a name field.

A fix for this issue was released in Lockable Resources Plugin version 2.4:

Release 2.4 (2019-1-18)
* JENKINS-46555 - Fix NPE on invalid entries.
This workaround was something you had used before, but couldn't recall the details of, so you should be good using it here.

Workaround

The workaround to resolve the issue is to:

  1. Manually view the $JENKINS_HOME/org.jenkins.plugins.lockableresources.LockableResourcesManager.xml file

  2. Remove the entries that have no <name> field

  3. Restart Jenkins

  4. Try again with regards to the lockable resource.

Tested product/plugin versions

References