Infinite total internal reflection
A physicist's answer to this is that the second law of thermodynamics forbids such a construction. You are describing a perfect black body, and the indefinite input of light in the way you propose will inevitably heat any finite cavity with the properties you propose. If your input light comes through a perfect waveguide from a black body at some temperature $T$, then the second law forbids the device's rising to a temperature above that of the source. So some light has to eventually leave the device.
However, what of trapping a short pulse of light (where the heating effect would not be a problem)?
There are contrived mathematical solutions to similar problems. For a 2D example, consider a perfect circular mirror with an infinitely thin slit in it for a ray to pass through (here we strike another difficulty of applying ray optics to this problem: real light cannot pass through an infinitely thin slit and indeed diffracts strongly on the far side if (1) the slit is much less than a wavelength width and (2) the wall thickness is thin enough for transmission through the slit. So already we must begin to consider full EM theory rather than rays. But let's state the ray solution for completeness:
Theangle $\Delta\theta$ between the angular positions of successive bounces is constant. This angle is a continuous function of the incidence angle, and equal to $\pi$ when the incidence angle is nought. Clearly all values of $\Delta \theta$ in some neighborhood $(\pi-\epsilon,\,\pi+\epsilon)$ of nought are reachable by adjusting the incidence angle. So we choose a $\Delta\theta$ that is an irrational multiple of $2\pi$. The ray hits the slit again (and thus escapes) after $n$ circulations, where $n\,\Delta\theta=2\,\pi,\,m$, for integers $n$ and $m$. But this is impossible if $\Delta\theta$ is an irrational multiple of $2\,\pi$, whence the device "swallows" such a ray permanently.
Take heed how infinite precision is needed for this argument: a nonzero width slit in this device will always lead to an eventual escape. To understand that there must be an eventual escape of the ray in this case, either $\Delta\theta$ is a rational multiple of $2\,\pi$, in which case it hits the slit precisely after some finite number of bounces, or it is an irrational multiple of $2\,\pi$. If the latter case, it can be shown that the set of intersection points where the ray bounces from the mirror is dense in the circle, therefore, any nonzero angular interval (and thus nonzero width slit) contains at least one of these intersections, so the ray escapes in this case too.
We can make a more realistic ray solution escape proof. A strip of horizontal light rays will be trapped by a Cassegrain like structure with two arcs of parabolas with common focus and vertical directrices will do it:
See this MathOverflow Thread "Symmetric Black Hole Curves" for more information. But this solution also has the catch that the incoming ray must be perfectly horizontal for trapping to happen. Since diffraction is roughly tantamount to a nonzero angular spread of rays, this means that real light will eventually escape such a structure.
A counter-argument to all the naysayers :-) .
First of all, the evanescent wave has nothing to do with light escaping. For example, single-mode fiber optics are often designed such that there's a significant evanescent wave, but since there's no high-index material outside the core, no energy escapes (other than quantum probabilistic long-range tunneling).
Next, and this is the unobtanium part, suppose you shoot a particle and its antiparticle into a, say, octagonal right prism, such that the photons generated when they destruct are emitted in the prism plane and at an angle equal to the face angle, which is also less than the critical angle for the prism material. Those photons will bounce from face to face forever.
The answers here is beautiful. But, i’ll give another simple example. Just take a glass square. The critical angle of glass is 42 degree. So pass a light ray through a very small slit , such that it strikes the side of the square glass slab, at 45 degrees. It will reflect and will ALWAYS strike the faces of the slab at angles greater than 45 degrees. And you’re in business!