Violation of Stefan's law when shining a light on a black body Suppose there is a black body in a dark room and the room temperature is constant. Now a ray light is shone upon it. Since a black body absorbs all radiation that falls upon it, it must absorb more radiation than it did when no light fell on it, but according to Stefan's law, the radiation absorbed depends only on the ambient temperature (which is constant).
I feel like I haven't completely understood the concept of black bodies since the two explanations are contradicting each other.
 A: Stefan-Boltzmann law
The Stefan-Boltzmann law says quite simply that the thermal power $P_\text{thermal}$ emitted by a black body at temperature $T$ is $$ P_\text{thermal}(T) = A \sigma T^4$$ where $A$ is the object's surface area and $\sigma$ is a constant
$$ \sigma \equiv \frac{2 \pi^5 k_b^4}{15 c^2 h^3} \, .$$
This law is always true as long as the black body can be said to be at a certain temperature.
Addressing the original question

Now a ray a light is shone upon it. Since a black body absorbs all radiation that falls upon it, it must absorb more radiation than it did when no light fell on it...

Correct so far.

but according to Stefan's law the radiation absorbed depends only on the ambient temperature (which is constant).

That's not correct.
The Stefan-Boltzmann law says that the power emitted by a black body depends only on its temperature.
The power absorbed depends on how much radiation is coming onto the black body, and that radiation does not necessarily have to be coming from an environment in thermal equilibrium.
The incoming radiation can be of essentially two different types:

*

*Thermal radiation, i.e. radiation emitted from objects that various other temperatures ("objects" here include space, actually).


*Coherent radiation, i.e. light from a laser.
To some rough approximation, most natural electromagnetic radiation has properties that put it somewhere between fully thermal and fully coherent light $^{[a]}$.
Suppose the black body is initially at temperature $T_i$ and is sitting in a room, also at temperature $T_i$ with no light sources.
In this case, the object is at thermal equilibrium so the power absorbed and emitted must be the same.
We know from the Stefan-Bolzmann law that this power is
$$ P_\text{thermal (absorbed and emitted)}(T) = A \sigma T^4 \, . $$
If we now turn on a light source (e.g. a laser) with power $P_\text{source}$ and point it at the body, then the total power flow into the black body is
$$
P_\text{in}
=
\underbrace{P_\text{source}
+ P_\text{thermal}(T_i)}_\text{absorbed} \, \,
\underbrace{- P_\text{thermal}(T_i)}_\text{emitted}
\, .
$$
At first, the emitted and absorbed thermal powers are equal, so they cancel and the total power into the black body is $P_\text{source}$.
Since the black body is absorbing more than it's emitting, it's temperature starts to go up.
Therefore, by definition, the system is no longer said to be in thermal equilibrium.
Suppose the black body absorbs enough power that its temperature rises to $T$, while the surrounding environment is so big that no matter how much energy it absorbs, its temperature is still approximately $T_i$.
Then the power going into the black body is
$$
  P_\text{in}
  =
  P_\text{source}
  + P_\text{thermal}(T_i)
  - P_\text{thermal}(T)
  \, .
$$
This system is never truly in equilibrium because we're constantly adding energy through $P_\text{source}$, but there is a "steady-state" where the temperatures of the objects stop changing.
That happens when $P_\text{in} = 0$, i.e. when the total incoming and outgoing power from the black body are equal, i.e. when
\begin{align}
 P_\text{in} &= 0 \\ 
  \underbrace{P_\text{thermal}(T_f)}_\text{emitted}
  &=
  \underbrace{P_\text{source} + P_\text{thermal}(T_i)}_\text{absorbed}
\end{align}
where $T_f$ is the final steady state temperature of the black body.
Homework: Solve for $T_f$ in terms of $P_\text{source}$ and $T_i$.
Side note
By the way, pretty much every single idea about "breaking the second law of thermodynamics" or making a "perpetual motion machine" comes down to someone misunderstanding that the theoretical results of equilibrium thermodynamics only apply in equilibrium.
[a]: I'm intentionally not explaining that in full detail because it would take us too far away from the main point.
A: Before the light was shone on the black body the temperature of the black body was constant because the rate at which energy was radiated out to the surroundings was equal to the rate at which it absorbed energy from the surroundings.
When the light was shone on the black body continuously and absorbed by the black body this would represent an increase in the energy content of the black body and that would manifest itself as an increase in the temperature of the black body above that of its surroundings.
This would mean that the black body would start radiating out more energy than it did before and so there would be a net outflow of radiation from the black body.
Eventually, an equilibrium state would be achieved when the rate at which the black body is gaining energy from the light is balanced by the net loss of radiant energy by the black body to its surroundings.
This would require the black body to be at a higher temperature than that of its surroundings.
