// on my case, instead of casting I did: Long variable = Long.valueOf(variable.get("Attribute").toString());