Projective and injective modules; direct sums and products

I need two counterexamples.

First, a direct sum of $R$-modules is projective iff each one is projective.
But I need an example to show that, “an arbitrary direct product of projective modules need not be a projective module.”

If I let $R= \mathbb Z$ then $\mathbb Z$ is a projective $R$-module, but the direct product $\mathbb Z \times \mathbb Z \times \cdots$ is not free, hence it is not a projective module. We have a theorem which says that every free module over a ring $R$ is projective. Am I correct?

Second, a direct product of $R$-modules is injective iff each one is injective
but I need an example to show that the direct sum of injective modules need not be injective.

Solutions Collecting From Web of "Projective and injective modules; direct sums and products"

As for the first question: yes, $P = \prod_{i=1}^{\infty} \mathbb{Z}$ is a direct product of free $\mathbb{Z}$-modules which is not free. Since $\mathbb{Z}$ is a PID, $P$ is also not projective. The proof that $P$ is not free is nontrivial, but I believe it has already been given either here or on MathOverflow.

As for the second question: the Bass-Papp Theorem asserts that a commutative ring $R$ is Noetherian iff every direct sum of injective $R$-modules is injective. Thus every non-Noetherian ring carries a counterexample. The proof of the result — given for instance in $\S 8.9$ of these notes — is reasonably constructive: if

$I_1 \subsetneq I_2 \subsetneq \ldots \subsetneq I_n \subsetneq \ldots$

is an infinite properly ascending chain of ideals of $R$, then for all $n$ let $E_n =
E(R/I_n)$ be the injective envelope (see $\S 3.6.5$ of loc. cit.) of $R/I_n$, and let $E = \bigoplus_{n=1}^{\infty} E_n$. Then $E$ is a direct sum of injective modules and (an argument given in the notes shows) that $E$ is not itself injective.