Also make sure if you deploy in Glassfish externally (not locally) to remove duplicate dependencies in the lib folder of the Glassfish installation on that server.
In my case, everything worked fine locally but once deployed on a server I got this error.