When can't a real definite integral be evaluated using contour integration?

Solution 1:

There are such functions. For example, anything with infinitely many discontinuities. Take the Dirichlet function as an example; it is Lebesgue integrable, but one could not integrate it using the method of residues, which requires that there are only finitely many poles of the function on the real line.