(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:
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:
-------------------------------------bug report------------------------------------------
strayan@netbeans.org 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/
I was facing the same problem in case of PostgreSQL and performed the following steps for successful database connection with Netbean:
Now based on this resource you can create entities and whole EJB stuff without any problem.