Search code examples
jakarta-eenetbeansjdbcglassfishconnection-pooling

Glassfish: the name of the driver class for the datasource is missing


(scroll to end for possible bug this relates to.)

this connection pool seems correct, at least the ping is successful, but how is it actually referenced by the EJB module?

thufir@dur:~$ 
thufir@dur:~$ glassfish-4.1/glassfish/bin/asadmin
Use "exit" to exit and "help" for online help.
asadmin> 
asadmin> list-jdbc-connection-pools
CLI031: Warning: Option "target" is obsolete and will be ignored.
CLI031: Warning: Option "target" is obsolete and will be ignored.
__TimerPool
DerbyPool
SamplePool
connectionPool
legacy_on_glassfish
Command list-jdbc-connection-pools executed successfully.
asadmin> 
asadmin> ping-connection-pool legacy_on_glassfish
Command ping-connection-pool executed successfully.
asadmin> 
asadmin> list-jdbc-resources
jdbc/sample
jdbc/__TimerPool
jdbc/__default
jdbc/local
jdbc/legacy_resource
Command list-jdbc-resources executed successfully.
asadmin> 

(I wasn't sure how to output the jdbc connection propertes with asadmin)

Using the Netbeans wizard, this is the resulting persistence.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  <persistence-unit name="EnterpriseLegacyJDBC-ejbPU" transaction-type="JTA">
    <jta-data-source>jdbc/legacy_resource</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
      <property name="javax.persistence.schema-generation.database.action" value="create"/>
    </properties>
  </persistence-unit>
</persistence>

However, choosing "New Entity Classes from Database" results in:

name missing

From the Glassfish console, what is the name of the driver class for the datasource?

looking in the console, the Datasource Classname is com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource, while the Driver Classname isn't editable:

enter image description here

-------------------------------------bug report------------------------------------------

[email protected] 2013-11-25 09:13:49 UTC

Sorry for the confusion, when you create the DataSource from the NetBean IDE like mentioned in the tutorial it works fine like you said. But when selecting a DataSource that is created outside (using GlassFish Server Admin console) of the IDE which shows in the IDE we see the error.

https://netbeans.org/bugzilla/show_bug.cgi?id=238667#c19

However, I'm not sure what's meant by a DataSource created use the GlassFish Server Admin console -- just can't find that option.

see also:

http://computingat40s.wordpress.com/how-to-setup-a-jdbc-connection-in-glassfish/


Solution

  • I was facing the same problem in case of PostgreSQL and performed the following steps for successful database connection with Netbean:

    1. Remove all the connection pools and data sources created by you from GlassFish using admin console
    2. Right-click the project name in NetBeans.
    3. Select New->Other->Glassfish->JDBC Connection Pool.
    4. Click Next.
    5. Give pool name.
    6. Select New Configuration using Database.
    7. Select Postgres from drop down list.
    8. In next step Enter these six parameters and their values:
      • User - postgres;
      • DatabaseName - (your DB name);
      • ServerName - localhost;
      • PortNumber - 5432;
      • Password - (password of postgre);
      • URL - jdbc:postgresql://localhost:5432/DBname
    9. Right-click the project
    10. Select New->Other->Glassfish->JDBC Resource.
    11. Select Use existing JDBC Pool.
    12. Select the pool name you have created in previous bullet.
    13. Set the name of resource
    14. Click Finish.

    Now based on this resource you can create entities and whole EJB stuff without any problem.