For a charged air-dielectric capacitor, let the plates be parallel to the $xy$ plane, with the top carrying a positive charge $+Q$, the bottom a charge $-Q$. The force on an infinitesimal charge contained in a volume $dv$ inside the top plate is
$$-\vec E_z\rho(x,y,z)dv$$
Integrating this over the volume of the plate gives the total force on its center of mass as $$-\vec E_z Q$$ which becomes using Gauss's law
$$-\hat n_z E^2A\epsilon_0$$
If the plates are moved apart a distance $dz$ by an opposing force $\vec F$, the infinitesimal work done is $E^2\epsilon_0Adz$, and integrating this from zero to their final separation $d$ gives the energy density as $E^2\epsilon_0$.
But this is different to the correct value of $1/2E^2\epsilon_0$, so where's the flaw in the above argument?