After hours of search and trials I came to the conclusion that there is some problems with Payara and standalone-clients.
You should use gf-client.jar FROM THE INSTALLATION's DIRECTORY in your project. DON'T copy the file! and that's it!
If you only use that it will work with Glassfish 7.0.21 (that was what I used). Exactly the same code doesn't work with Payara 6.2024.5 (that was what I used).
For Payara the problem has noting to do with libraries etc., it is just a bug.