Glassfish is not loading the com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
package.
The following error is thrown
javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence
Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException:
Error in allocating a connection. Cause: Class name is wrong or classpath is not set
for:com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
Error Code: 0 at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy
(EntityManagerSetupImpl.java:517)...
I have copied the mysql-connector jar file to the lib
directory of Glassfish but I still get the above error.
How do I ensure that Glassfish can find my JDBC driver for my deployed application?
You will need to make the MySQL JDBC jar file available to Glassfish.
http://ushainformatique.com/blog/2010/03/19/jdbcwithglassfish/
EDIT:
It is recommended to place JDBC drivers, that are used by all the applications in the domain, in domain-dir/lib or domain-dir/lib/classes. A restart of the application server instance is required today so that the JDBC drivers are visible to applications deployed in the domain.
From https://blogs.oracle.com/sivakumart/entry/classloaders_in_glassfish_an_attempt
So move the jar file into the lib dir below the domain into which you are deploying your app. The default Glassfish domain is domain1.
Restart Glassfish and this should work.
There is a Maven Glassfish plugin which may be worth evaluating http://maven-glassfish-plugin.java.net/ Using Maven and this plugin would help automate the deployment step. This would be more robust than doing manual deployments. Your call though of course.