ResourceException: Class name is wrong or classpath is not set for MysqlDataSource

0

currently I am following this link

to solve

Caused by: javax.resource.ResourceException: Class name is wrong or classpath is not set for : com.mysql.cj.jdbc.MysqlDataSource

So, I added mysql-connector-java-5.1.46.jar to my glassfish installation as shown in the screenshot below:

Glassfish installation directory

After a restart of Glassfish I my .war still does not deploy with the same error message (stacktrace below)

Caused by: javax.resource.ResourceException: Class name is wrong or classpath is not set for : com.mysql.cj.jdbc.MysqlDataSource
    at com.sun.gjc.common.DataSourceObjectBuilder.getDataSourceObject(DataSourceObjectBuilder.java:278)
    at com.sun.gjc.common.DataSourceObjectBuilder.constructDataSourceObject(DataSourceObjectBuilder.java:117)
    at com.sun.gjc.spi.ManagedConnectionFactoryImpl.getDataSource(ManagedConnectionFactoryImpl.java:1383)
    at com.sun.gjc.spi.DSManagedConnectionFactory.getDataSource(DSManagedConnectionFactory.java:163)
    at com.sun.gjc.spi.DSManagedConnectionFactory.createManagedConnection(DSManagedConnectionFactory.java:102)
    at com.sun.enterprise.resource.allocator.LocalTxConnectorAllocator.createResource(LocalTxConnectorAllocator.java:87)

Does anyone know how to solve the problem? Thank you.

Heilmann

Posted 2019-04-04T07:51:23.267

Reputation: 1

Answers

0

I solved it by adding this dependency to my pom.xml

<dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.14</version>
        </dependency>

instead of placing the mysql-connector-java-8.0.14.jar into /payara5/glassfish/domains/domain1/lib.

Heilmann

Posted 2019-04-04T07:51:23.267

Reputation: 1

Great! Be sure to accept this as the correct Answer. – HazardousGlitch – 2019-04-04T09:15:55.517