This strikes me as, "Right answer, wrong reason." Consider the classic magnetostatics problem that you can solve using Ampere's law, the infinitely long current carrying wire with uniform current density $J$ and radius $R$. Using Ampere's law you'll find that
\begin{align}
\mathbf{B}(r) &= \left\{\begin{array}{ll}
\mu_0\frac{J\pi R^2}{2\pi r} \hat{\phi} & r \ge R \\
\mu_0\frac{J\pi r^2}{2\pi r}\hat{\phi} & r < R. \end{array}\right.
\end{align}
Inside the wire the curl of $\mathbf{J}$ is zero, same for outside the wire. At the surface of the wire, though, the curl of $\mathbf{J}$ has a spike (Dirac delta function) in it that you can verify using Stoke's theorem.
The correct answer is that the derivation the book gave is ambiguous. Kanos's answer provides one alternative, but the vector potential is not needed. What you really need is to express the relationship using notation that is a little more detailed, but unambiguous. We split the $r$ from the Biot-Savart law to get two independent variables - one that is an integration variable, the other that is not.
$$\mathbf{B}(\mathbf{r}) = \frac{\mu_0}{4\pi} \int \mathbf{J}(\mathbf{r}')\times \frac{\mathbf{r}-\mathbf{r}'}{\left|\mathbf{r}-\mathbf{r}'\right|^3} \operatorname{d}^3 r'.$$
Notice: $\mathbf{J}(\mathbf{r}')$ is not a function of $\mathbf{r}$, so when you try to take any derivatives with respect to any $\mathbf{r}$ coordinate you'll get zero.
So, we get:
\begin{align}
\nabla\cdot \mathbf{B}(\mathbf{r}) & = \frac{\mu_0}{4\pi} \int \nabla\cdot \left[\mathbf{J}(\mathbf{r}')\times \frac{\mathbf{r}-\mathbf{r}'}{\left|\mathbf{r}-\mathbf{r}'\right|^3} \right] \operatorname{d}^3 r'.
\end{align}
Now, apply the vector calculus cross product identity, $\nabla\cdot(\mathbf{A}\times\mathbf{B}) = (\nabla\times \mathbf{A})\cdot \mathbf{B} - \mathbf{A}\cdot(\nabla\times\mathbf{B})$ with $\mathbf{A}=\mathbf{J}$ and $\mathbf{B}=\frac{\mathbf{r}-\mathbf{r}'}{\left|\mathbf{r}-\mathbf{r}'\right|^3}$ to get
\begin{align}
\nabla\cdot \mathbf{B}(\mathbf{r}) & = \frac{\mu_0}{4\pi} \int \left[(\nabla\times\mathbf{J}(\mathbf{r}'))\cdot \frac{\mathbf{r}-\mathbf{r}'}{\left|\mathbf{r}-\mathbf{r}'\right|^3} - \mathbf{J}(\mathbf{r}')\cdot \left(\nabla\times\frac{\mathbf{r}-\mathbf{r}'}{\left|\mathbf{r}-\mathbf{r}'\right|^3} \right)\right] \operatorname{d}^3 r'.
\end{align}
The first cross product vanishes because $\mathbf{J}(\mathbf{r}')$ is not a function of $\mathbf{r}$ and $\nabla$ is a derivative in the $\mathbf{r}$ coordinates. That the second cross product vanishes can be shown using a little algebra, or some tricks discussed in other answers.