Magnetic field of a finite conductor cylinder

I'm trying to calculate the magnetic field outside a finite cylinder of radius R and height 2H, whose axis is the z-axis. Through the cylinder is flowing a constant current density $$\vec{J} = J_0 \vec{u}_z$$. By applying Biot-Savart's law:

$$\vec{B} = \frac{\mu_0}{4\pi} \int_0^R \int_0^{2\pi} \int_{-H}^H \frac{J_0 (\rho - \rho')\rho' d\rho' d\phi' dz'}{((\rho-\rho')^2 + (z-z')^2)^{3/2}}\vec{u}_\phi$$

However, as $$\vec{u}_\phi = -\sin \phi' \vec{u}_x + \cos \phi' \vec{u}_y$$, that integral vanishes. And that is not coherent with the result obtained for an infinite cyilinder applying Ampère's law.

Does anyone know what's happening there? Thanks in advance.

• since there is no $\phi$ dependence under the integral, why isn't $\int_0^{2\pi}{d\phi} = 2\pi$? – JEB Apr 16 at 21:27
• When unitary vectors depend on $\phi$, that dependence must be taken into account in order to be integrated. That's what I understood. – Miguel Ibáñez Apr 17 at 8:15
• I think you need to clarify your notation then. Isn't $\hat{\phi}$ (can't do the $u$-thing) associated with $B(\rho,\phi, z)$ and not $J(\rho', \phi', z')$ so that it is outside the integral? – JEB Apr 17 at 14:19
• $\hat{\phi}$ is the result of making the cross product of $\vec{J}$ (that is $\vec{J} = J_0 \hat{z}$) and $(\vec{r}-\vec{r}')$ (that is $\vec{r} - \vec{r}' = (\rho - \rho')\hat{\rho} + (z-z')\hat{z}$). I guess it's associated with $J$, but I'm not sure at all... – Miguel Ibáñez Apr 17 at 17:43