Semicoercive variational problems at resonance: an abstract approach