As far as I understand, the problem is not related to the provided code, it is related to the missing CTPageMar class.
The source of the problem with the missing classes is clearly explained in the Apache POI FAQ :
To use the new OOXML file formats, the POI requires a jar containing the XSD file format [...] You can manually download the jar from the Maven POI repository.
The URL from the frequently asked questions does not work, but you can find the required jar in the central maven repo .
source share