Try with following code:
VariableScopeInstance variableScope = (VariableScopeInstance) processInstance.getContextInstance(VariableScope.VARIABLE_SCOPE);
Map<String, Object> variables = variableScope.getVariables();
just make sure that process instance is of type org.jbpm.process.instance.ProcessInstance
HTH