Deployment in classpath for Glassfish not installed for com.mysql.jdbc.jdbc2.optional.MysqlXADataSource

Glassfish does not load the package com.mysql.jdbc.jdbc2.optional.MysqlXADataSource .

The following error is raised:

 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 copied the mysql connector file jar file to the Glassfish lib directory, but I still get the above error.

How can I ensure that Glassfish can find my JDBC driver for my deployed application?

+6
source share
3 answers

You will need to make the JAR file for MySQL JDBC available to Glassfish.

http://ushainformatique.com/blog/2010/03/19/jdbcwithglassfish/

EDIT:

How to use different JDBC drivers? Where should I copy the jar?

It is recommended to host JDBC drivers that are used by all applications in the domain, in the 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

Move the jar file to the lib directory below the domain into which you are deploying the application. The default domain for Glassfish is domain1.

Restart Glassfish and it should work.

There is a Maven Glassfish plugin that can be rated http://maven-glassfish-plugin.java.net/ Using Maven, and this plugin will help automate the deployment step. This will be more reliable than manual deployment. Of course your call.

+9
source

In addition to adding a driver to your class path, try adding the appserv-rt.jar file to your project build path (the jar is in the Glassfish lib directory). If you do not want to include all other banks, first create a library containing the appserv-rt banner, and then add it to your project construction path.

+2
source

We could fix it. / asadmin start-database This starts Derby (I don’t know why this is required, there may be a mistake, and I do not use this database in my application) :)

-2
source

Source: https://habr.com/ru/post/917705/


All Articles