In 1485, Moldavian prince Stephen the Great, having lost his country's access to the Black Sea the previous year to the Ottomans, was in serious need of alliances, and swore allegiance to Casimir IV Jagiellon, King of Poland, in exchange of Pokuttia, in what is known as the "Colomeea oath". Casimir's successor, John I Albert of Poland, used the aforementioned treaty as a pretext to invade Moldavia itself in 1497. However, after four months of siege, he failed to take the fortress of Suceava, Moldavia's capital, and abandoning the siege, his army ran into a trap that caused many of his nobles to die (Battle of the Cosmin Forest).