Existence and homogenization for semilinear elliptic equations with noncompact nonlinearity