wood burning stoves 2.0*
The moose likes Glassfish and the fly likes Glassfish SQLException: Error in allocating a connection in MySQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Glassfish
Bookmark "Glassfish SQLException: Error in allocating a connection in MySQL" Watch "Glassfish SQLException: Error in allocating a connection in MySQL" New topic
Author

Glassfish SQLException: Error in allocating a connection in MySQL

Jack Bush
Ranch Hand

Joined: Oct 20, 2006
Posts: 235
Hi All,

I have just installed the Bundled Netbeans 6.5, Glassfish v2 and v3 Prelude (not including MySQL) that runs on top of MySQL 5.1 (separate installation) on server A, in order to mirror another similar working installation (Bundled Netbeans 6.1, Glassfish v2 including MySQL 5.0) on server B. Both Windows XP servers have got identical setups in their respective C:\Program Files\glassfish-v2ur2\domains\domain1\config\domain.xml files. However, the following error was encountered when trying to deploy the same EnterpriseApplication on server A which had no such problem on server B:

[u]Glassfish Server Log[/u]
[b]Server: unknown
RAR5099 : Wrong class name or classpath for Datasource Object
java.lang.ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1498)
at com.sun.gjc.common.DataSourceObjectBuilder.getDataSourceObject(DataSourceObjectBuilder.java:251)
at com.sun.gjc.common.DataSourceObjectBuilder.constructDataSourceObject(DataSourceObjectBuilder.java:106)
RAR5038:Unexpected exception while creating resource for pool mysqlPool. Exception : Class name is wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource
RAR5117 : Failed to obtain/create connection from connection pool [ mysqlPool ]. Reason : Class name is wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource
RAR5114 : Error allocating connection : [Error in allocating a connection. Cause: Class name is wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource]
Exception occured in J2EEC Phase
com.sun.enterprise.deployment.backend.IASDeploymentException:
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.MysqlConnectionPoolDataSource
Error Code: 0
at oracle.toplink.essentials.exceptions.DatabaseException.sqlException(DatabaseException.java:305)[/b]
[u]EnterpriseApplication (EJB 3.0) Deployment output[/u]
[b]Deploying application in domain failed; Deployment Errorjava.sql.SQLException: Error in allocating a connection. Cause: Class name is wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource --
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.MysqlConnectionPoolDataSource
Error Code: 0
C:\Documents and Settings\Jack\EnterpriseApplication\EnterpriseApplicationBean-ejb\nbproject\build-impl.xml:400: The module has not been deployed.[/b]

Even manually re-creating the same project (as opposed to getting a copy of the Netbeans project folder from server B) did not make any difference. Likewise, the following jdbc connection pool definition was added possibly by Netbeans from Server Database JDBC Connection Resource setting:

<property name="URL" value="jdbc:mysql://localhost:3306/employeeDB"/>
<property name="driverClass" value="com.mysql.jdbc.Driver"/>
<property name="Password" value="abcdef"/>
<property name="portNumber" value="3306"/>
<property name="databaseName" value="employeeDB"/>
<property name="serverName" value="localhost"/>
<property name="User" value="applicationuser"/>

Can anyone see where the problem lies?

This question has also been posted in [url]http://forums.sun.com/thread.jspa?threadID=5371226[/url] wihtout getting a correct answer.

Any assistance would be much appreciated.

Thanks in advance,

Jack
komarios marios
Greenhorn

Joined: Dec 14, 2009
Posts: 4
As far as I can see you need to install mysql jdbc library to all the instances and configure the connection pool on all servers.
A simple tutorial for a mysql connection pool on GlassFish can be found here :

http://mariosgaee.blogspot.com/2009/12/mysql-connection-pool-in-glassfish.html
Parwaneh Wilb
Greenhorn

Joined: May 04, 2008
Posts: 3
Because I always have trouble configuring web apps in Glassfish, I want to share my experience. I hope this helps someone...

This is for Glassfish 3.1.1 and mysql-connector-java-5.1.18.tar.gz.

I put mysql-connector-java-5.1.18-bin.jar in glassfish3/glassfish/domains/domain1/lib/databases and got the same error as Jack Bush:
Wrong class name or classpath for Datasource Object java.lang.ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource

After a loooong time I found out, that everything works, if I put the .jar directly in glassfish3/glassfish/domains/domain1/lib.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Glassfish SQLException: Error in allocating a connection in MySQL
 
Similar Threads
Java EE 6 Glassfish App problem
Unable to inject @Resource into ApplicationClient using ACC
MySQL & Sun App Server
sun one app server and connection pool
MySQL JDBC ConnectionPool Configuration in GrassFish v2.1