In Jackson- Classical Electrodynamics when resonant cavities are discussed (8.6, page 252) (but also at page 7 here or at page 19 here) the explanation is made by saying that the solution is the same of a rectangular waveguide, which we can suppose that is for $E$
$$\mathbf{E}(x,y,z,t)=\mathbf{E_0}(x,y) e^{i(\alpha z-\omega t )}$$ $$\mathbf{B}(x,y,z,t)=\mathbf{B_0}(x,y) e^{i(\alpha z-\omega t )}$$
but instead of $e^{i(\alpha z )}$ there is a factor $H \cos(wz)+J \sin(wz)$, so $$\mathbf{E}(x,y,z,t)=\mathbf{E_0}(x,y) [H \cos(wz)+J \sin(wz)]e^{-i \omega t }$$ $$\mathbf{B}(x,y,z,t)=\mathbf{B_0}(x,y) [H' \cos(wz)+J' \sin(wz)]e^{-i \omega t }$$ And the boundary conditions imposed are teh following (supposing the lenght of cavity to be $d$ in $z$ direction) $$B_z(z=0)=B(z=d)=0 \,\,\,\,\,\,\,\,\,\,\, \forall x,y \tag{1}$$ $$E_x(z=0)=E_x(z=d)=E_y(z=0)=E_y(z=d)=0 \,\,\,\,\,\,\,\,\,\,\, \forall x,y \tag{2}$$
While $(2)$ is clear because it simply requires the electric field to be normal to the surface (which is the necessary condition to avoid dissipation), I do not see why $(1)$ is required.
It would be explained by the fact that $E$ is perpendicular to $B$ but that's a conclusion that one should get from the solution, not an assumption to impose the boundary conditions. Unfortunately I did not find an explanation for $(1)$ neither on Jackson neither on the references so why is $(1)$ a necessary boundary conditions to impose?