The problem read as follows,
Consider an infinite cylinder (in $z$) and with external radius also infinite. In the cylinder flows a current defined by a superficial current density given by:
$$J(r, \theta) = \frac{J_{0} R^2}{r^2}\cos(\theta) \qquad \left[\text{with unit }\frac{\rm A}{\rm m^2}\right]$$
Evaluate the $x$ and $y$ components of the magnetic field in point $P$.
The schematic is,
Here are my attempts:
If I get the idea correctly, there is no current flowing in the inside wire, i.e., $r \leq R$, only for $r > R$.
I have drawn an amperian loop $\mathscr{C}$ with radius $r$, such that $r > R$ and applied Ampere's Law to it.
$$\nabla \times \vec{H} = \vec{J}$$ $$\oint_\mathscr{C} \vec{H} \cdot d\vec{l} = \int_S \vec{J} \cdot d\vec{S}$$
$$I_\text{enclosed} \equiv \int_S \vec{J} \cdot d\vec{S}$$.
Ok, so changing to polar coordinates, we will have $dS = r\ dr\ d\theta$. If I define $d\vec{S}$ outwards the cross section as is $\vec{J}$, we get
$$I_\text{enclosed} \equiv \int_S J dS = \int \int \frac{J_{0} R^2}{r^2}\cos(\theta)\cdot r\ dr\ d\theta$$
Here's the issue: should I integrate $r$ for $R < r < +\infty$? If so, then the integral diverges. Should I integrate $\theta$ for $0 < \theta < 2 \pi$? Then the magnetic field is null, which is inconsistent, since in that region there is a current enclosed by the Amperian loop.