Banana Joe

Bud Spencer plays Banana Joe, a brawny yet friendly man who lives in a small rainforest village called Amantido with a huge number of his own children and regularly delivers bananas to a South American river port (hence his name). One day, the henchmen of a local gangster boss named Torsillo come ashore in Amantido to initiate the construction of a banana processing plant. Of course, Joe (in typical direct-approach manner) evicts the goons, who promptly return to their boss.
Torsillo finds out that Joe is trading bananas without a license and decides to exploit it. Upon his next delivery, Joe is apprehended by the police and given the choice of either acquiring a legal license or getting his boat impounded and himself arrested for illegal shipment. Joe travels to the nearest city, which to him is a new world, as he grew up in the rainforest. Unfamiliar with city life and only marginally literate, he falls prey to a con man named Manuel, who has a gift of the gab which has placed him in favor in several high positions, even with the country's President for his help in developing a remedy for a genetic defect in the Presidential family.
Eventually Joe meets Dorianne, an attractive singer, in a bar owned by Torsillo, where he gets a temporary job as a bouncer. Torsillo also runs into Joe personally time and again, and after having seen Joe easily finishing off five of his toughest goons, the gangster boss has taken to jumping out of the next window in a panic the instant he lays an eye on Joe.
In pursuit of his license, Joe finds out that he must get himself registered with the authorities in order to "exist" legally. Since he has no proper official records, however, this proves highly difficult, and the constrictions and loop-holes of bureaucracy provide no help in resolving the matter. Joe even has to enlist in the Army, but after driving his drill sergeant to the point of despair and even to degradation, he deserts and lands himself in prison when in his impatience he takes matters (literally) into his own hands. In prison he re-encounters Manuel, whom he intends to pay back for his schemes, but it turns out that the con man actually has a heart of gold: Having taken pity on Joe's plight, he has used his connections to get Joe the much-needed license. From Dorianne, who visits him in prison, Joe learns that Torsillo has used his absence to facilitate the construction of the banana plant.
Joe and Manuel promptly break out of prison and return to Amantido, where Joe proceeds to thrash Torsillo's thugs and a newly built casino. Afterwards the police arrive, but not to arrest Joe. Instead they've been looking for Manuel: his remedy he had concocted for the President has worked, and Manuel (and Joe as well) receive amnesty as well as the fulfilment of a wish (Manuel decides to become Minister of Finance). To top it off, Torsillo is revealed to be no stranger to the authorities, and he and his entourage get arrested immediately. Dorianne decides to stay with Joe in Amantido, where she opens a school which Joe also attends, and Joe's life goes otherwise back to normal.

Question: How did Joe land in prison?
Answer: Deserted from the Army