Difference between solution for Rectangular hollow wave guide and resonant cavity In Griffith's Introduction to Electrodynamics, he solves for $\vec{E}$ and $\vec{B}$ in a Rectangular waveguide assuming they take the "generic form"
$$\vec{E}(x,y,z,t) = \vec{E_0}(x,y) e^{i(kz-wt)},\\ 
\vec{B}(x,y,z,t) = \vec{B_0}(x,y) e^{i(kz-wt)}$$
Where he assumes that $\vec{E_0}$ and $\vec{B_0}$ only depend on $x$ and $y$ without giving much of an explanation of why they cannot depend on $z$.
Then in Problem 40 of this chapter(9), where he solves for the fields of a "Resonant cavity" he assumes solutions of the form
$$\vec{E}(x,y,z,t) = \vec{E_0}(x,y,z) e^{-iwt},\\
\vec{B}(x,y,z,t) = \vec{B_0}(x,y,z) e^{-iwt}$$
where now $\vec{E_0}$ and $\vec{B_0}$ can depend on $x$, $y$ and $z$.
So my question is why do we only consider $\vec{E_0}$ and $\vec{B_0}$ that depend on $x$ and $y$ in the first case? i.e. why can't they depend on $z$?
and why do we consider $\vec{E_0}$ and $\vec{B_0}$ that can depend on $x,y,z$ in the second case?
 A: When solving Maxwell (or wave) equations in a cylindrical pipe one uses separation of variables technique, which straightforwardly leads to the distribution of field in xy plane being independent on $z$ and vice versa. If, in addition, the waveguide is rectangular, one can also separate $x$ and $y$ variables.
The statements regarding the cavity are quite general, without assuming any specific geometry - the cavity could be a rectangular box, or a spherical shell, or something of irregular form. In simple geometries, like cylindrical cavity or a rectangular box the separation of variables would still work.
A: Griffith assume the waveguide as hollow pipe with electromagnetic waves confined to its interior. He also assumes that waveguide is perfect conductor, so that E = 0 and B = 0 inside the material itself. Hence, TEM waves cannot occur in this hollow waveguide.
In the case of the rectangular waveguide, the assumption that E0→ and B0→ only depend on x and y is made because the waveguide is assumed to have an infinite extent in the x and y directions, while its extent in the z direction is finite. This means that the electromagnetic fields inside the waveguide can have a dependence on x and y, but not on z. This is because the fields must be periodic in the z direction, with a period equal to the length of the waveguide, in order to maintain the wave-like character of the fields.
In the case of the resonant cavity, the assumption that E0→ and B0→ can depend on x, y, and z is made because the cavity is now a closed and bounded system, and the electromagnetic fields can have a more general dependence on all three dimensions. This leads to the solution for the electromagnetic fields in a resonant cavity being more complex than for a rectangular waveguide, as the fields must now satisfy the boundary conditions imposed by the walls of the cavity, in addition to being periodic in the z direction.
