com.mysql.jdbc.jdbc2.optional.MysqlDataSource Error

0

I have a RESTful service created in Netbeans that connects to a remote mysql database. In local the service works well, but when I deploy it to the remote Glassfish server I get this error:

> Error occurred during deployment: Exception while deploying the app
> [JerseyRESTfulService] : Exception [EclipseLink-4002] (Eclipse
> Persistence Services - 2.6.1.v20150605-31e8258):
> 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.MysqlDataSource Error Code: 0. Please
> see server.log for more details.

The name of the class or classpath that says it is wrong, is put by Netbeans automatically when the service is generated. To which it refers? How could I solve it? I do not really know what value I should have. It is in the glassfish-resources.xml . Thanks.

    
asked by Montse 17.03.2017 в 17:40
source

1 answer

1

The error seems to indicate that the MySQL JDBC jar file is not available to Glassfish.

According to Oracle Doc:

  

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.

     

 It is recommended to place the JDBC drivers, which are   used by all applications in the domain, in    domain-dir/lib or domain-dir/lib/classes . A restart of the   instance of the application server is necessary for the   JDBC drivers are visible to applications.

Also, there is a Maven plugin for Glassfish that can help you. Using Maven and this add-on would help automate the deployment step. This would be more robust than manual implementations.

    
answered by 17.03.2017 в 18:29