Believe me, I know this question has been asked many times and has
gotten an answer many times, and these answers seemed to have worked for
some users. I've spent many hours trying the various proposed solutions
and, while they work on Linux (Ubuntu) and Windows 7 they seem to have no effect on
Windows (Windows 10 Home with jdk1.8.0_161). The web application is
using EclipseLink for persistence.
I've tried including the mysql-connector-java-5.1.46-bin.jar
file in the WAR archive (WEB-INF/lib
), copying it to the payara5/glassfish/lib
folder, as well as the payara5/glassfish/domains/domain1/lib/
and payara5/glassfish/domains/domain1/lib/applibs
folders. I also tried specifying the library when deploying the web application, i.e., putting mysql-connector-java-5.1.46-bin.jar
as the value in the library field. I updated the CLASSPATH
environment variable with the path to the JAR file. Every time, the
server was restarted. None of these actions have any effect. As said, note that
they did work on Linux Ubuntu and Windows 7. I've tried using EclipseLink 2.5.0, 2.5.2, 2.7.0 and 2.7.1, as well as mysql-connector-java-5.1.27-bin.jar
ll with no effect.and mysql-connector-java-5.1.46-bin.jar,a
See below for the well-known stack trace:
Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.0.v20170811-d680af5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/rom
Error Code: 0
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:331)
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:326)
at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:138)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:170)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.setOrDetectDatasource(DatabaseSessionImpl.java:228)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:804)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:254)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:757)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:216)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:324)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:348)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:311)
Interestingly, the error mentions Eclipse Persistence Services 2.7.0 regardless of the EclipseLink implementation that is included in the WAR file.
Any thoughts would be greatly appreciated.
payara5/glassfish/lib should work for a golbally defined datasource
WEB-INF/lib should work if you are defining the datasource in your web application web.xml or via annotations.
DriverManager.registerDriver(new com.mysql.cj.jdbc.Driver());