  The classical theorem of Weitzenboeck states that the algebra of invariants
of a single unipotent transformation $g$ in $GL_m(K)$ acting on the polynomial
algebra $K[x_1,...,x_m]$ over a field $K$ of characteristic 0 is finitely
generated. Recently the author and C.K. Gupta have started the study of the
algebra of $g$-invariants of relatively free algebras of rank $m$ in varieties
of associative algebras. They have shown that the algebra of invariants is not
finitely generated if the variety contains the algebra $UT_2(K)$ of $2\times 2$
upper triangular matrices. The main result of the present paper is that the
algebra of invariants is finitely generated if and only if the variety does not
contain the algebra $UT_2(K)$. As a by-product of the proof we have established
also the finite generation of the algebra of $g$-invariants of the mixed trace
algebra generated by $m$ generic $n\times n$ matrices and the traces of their
products.
