diff --git a/engine/components-api/src/org/apache/cloudstack/context/ServerContexts.java b/engine/components-api/src/org/apache/cloudstack/context/ServerContexts.java index ce4079a7e78..2c3757234a5 100644 --- a/engine/components-api/src/org/apache/cloudstack/context/ServerContexts.java +++ b/engine/components-api/src/org/apache/cloudstack/context/ServerContexts.java @@ -40,9 +40,11 @@ public class ServerContexts { public static void unregisterUserContext() { CallContext context = CallContext.unregister(); - AsyncJobExecutionContext.unregister(); - Transaction txn = (Transaction)context.getContextParameter("Transaction"); - txn.close(Thread.currentThread().getName()); + if (context != null) { + AsyncJobExecutionContext.unregister(); + Transaction txn = (Transaction)context.getContextParameter("Transaction"); + txn.close(Thread.currentThread().getName()); + } } /**