 As a result, he was promoted to Brigadier.On the accession of Joseph Bonaparte to the throne of Spain in 1808, Álvarez was commander of the castle of Montjuïc in Barcelona.On 29 February French troops arrived to take possession of the fortress.