James was probably one of the Gloucestershire WINNIATs - caught for one of those stupid things teenage boys still get up to. Three years is a long time at that age so he would have had plenty of time to reflect on his stupidity.
How does this punishment compare to nowadays? Here is a link to a similar case: http://www.peterboroughtoday.co.uk/news/Slab-on-tracks-pair-locked.4707759.jp
In the Criminal Court before Mr. Justice Hill.
"Mr. Gilmore Evans appeared for the prosecution; Mr. W. H. Cooke defended the prisoner.
"It appeared that on the 14th July last, when the train due at Bristol at 12/20 p.m. had arrived within a mile and a half of its destination, the engine-driver saw two boys placing something on the line, and as the train arrived near the spot he observed some stones, placed at intervals on the rails. The engine gave a lurch but it was not driven off the line, and in due course it arrived at Bristol, when the engine-driver complained of what had happened. A man was sent to the place, and found four boys there, of which the prisoner was one, but they all ran away. The prisoner was afterwards apprehended, and evidence was given to identify him as one of the persons who had placed stones upon the line.
"Mr. Cooke addressed the jury for the prisoner, and contended that there was not sufficient evidence of his identity. The jury, however, found him Guilty.
"Mr. Justice Hill, after pointing out the gravity of the prisoner's offence, sentenced him to 14 days' imprisonment, to be followed by three years' confinement in a reformatory.
"The rest of the day was chiefly occupied by the trial of cases the particulars of which are unfit for publication."
21st November, 1860, page 11 col d.