It is impossible to create a MenuPageInfo programmatically, because of a wrong usage of generics.
It only works through Spring, because spring ignores generics.
MenuPageInfo has an associated class, which should be a subclass of GeoServerBasePage.
However. MenuPageInfo extends ComponentInfo, rather than ComponentInfo<?extends GeoServerBasePage> that means that the associated class MUST be GeoServerBasePage.class itself, which doesn't make sense.