Consider for instance, the Cauchy distribution i.e. $f(x) = \dfrac1{\pi} \dfrac1{1+x^2}$ Clearly, $f(x)$ is a valid probability density function since $\int_{-\infty}^{\infty} f(x) dx = 1$ However, $\int_{-\infty}^{\infty} \dfrac1{\pi} \dfrac{x}{1+x^2} dx$ doesn't exist. This is so since if you "interpret" the integral $ \displaystyle \int_{-\infty}^{\infty} \frac{x}{x^2 + 1} dx$ as $\displaystyle \lim_{R \rightarrow \infty} \int_{-R}^{R} \frac{x}{x^2 + 1} dx$, then it is zero. (This is called the Cauchy principal value).
However, note that the integral $ \displaystyle \int_{-\infty}^{\infty} \frac{x}{x^2 + 1} dx$ can also be interpreted as, for instance, $\displaystyle \lim_{R \rightarrow \infty} \int_{-R}^{kR} \frac{x}{x^2 + 1} dx = \lim_{R \rightarrow \infty} \frac12 \log \left( \frac{1 + k^2R^2}{1 + R^2} \right) = \log(k) \text{ where }k > 0.$ You could also take other functions of $R$ such that the lower limit tends to negative infinity and upper limit tends to infinity as $R \rightarrow \infty$ to get different answers.
Hence, $ \displaystyle \int_{-\infty}^{\infty} \frac{x}{x^2 + 1} dx$ is not zero and in fact cannot be assigned any value unless you know how the lower limit and upper limit approach $\infty$.
This arises due to the fact the integral doesn't converge conditionally on $(-\infty, \infty)$ i.e. $\int_{-\infty}^{\infty} \vert x \vert f(x) dx = \int_{-\infty}^{\infty} \dfrac1{\pi} \dfrac{\vert x \vert}{1+x^2} dx = \infty$
Hence, $\displaystyle \int x f(x) dx$ is well-defined and exists only when $\displaystyle \int \vert x \vert f(x) dx < \infty$.