What worked for me was this:
I downloaded Glassfish 7.0.24 and discovered it ran my project without StackOverflow issues ( It uses Eclipselink 4.0.5) .
I copied all the org.eclipse.persistence.*.jar files from the glassfish/modules folder of glassfish 7 and pasted them in the glassfish/modules folder of Payara 6 .
Stopped the payara domain.
Deleted the osgi-cache and generated folder in the payara domain e.g domain1 .
Then restarted the Payara domain and redeployed the project.