This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 164814 - [67cat] EJB entity class generation can't find Postgres driver
Summary: [67cat] EJB entity class generation can't find Postgres driver
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 6.x
Hardware: PC Linux
: P3 blocker (vote)
Assignee: Sergey Petrov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-09 20:24 UTC by gholmer
Modified: 2013-12-27 02:44 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
screen shot (50.75 KB, image/png)
2009-05-12 21:58 UTC, gholmer
Details
messages.log (43.36 KB, text/plain)
2011-05-31 15:11 UTC, PeteX
Details
NetBeans log file (60.53 KB, text/x-log)
2013-09-13 16:25 UTC, gholmer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gholmer 2009-05-09 20:24:19 UTC
[ BUILD # : 200905080201 ]
[ JDK VERSION : 1.6.* ]

0) register external copy of GlassFish 2.1 in NetBeans
1) create Postgres database, create JDBC resource in GlassFish
2) create enterprise project in NetBeans
3) in EJB sub-project, create persistence unit: take TopLink as
default persistence provider, GlassFish JDBC data source is
recognized and used
4) right-click EJB sub-project and select "Entity classes from
database".
5) select same JDBC data source from step 3)
6) error dialog appears: "Unable to find the driver. Register this
driver in the databases tab."

The driver in NetBeans
(ide11/modules/ext/postgresql-8.3-603.jdbc3.jar) is the same one I
put in the lib/ directory of my GlassFish install.
Comment 1 gholmer 2009-05-12 21:58:16 UTC
I noticed something unusual in the tooltip I see when I hover over the selection I am about to make (see attached
screenshot).  Note that the database URL starts with "null" and has no name for that JDBC driver class name.  What does
this mean?
Comment 2 gholmer 2009-05-12 21:58:58 UTC
Created attachment 82006 [details]
screen shot
Comment 3 Sergey Petrov 2009-09-23 13:50:37 UTC
postrge installed failed to install database on my system, may need more time for evaluation.
Comment 4 Sergey Petrov 2009-10-06 13:14:49 UTC
I'm able to reproduce on 6.7 but with another error message (with 8.4-701 driver), but in nb 6.8 I'm able to create
entities from postresql database. 
Seems fixed for me, resoleve as worksforme,
but feel free to reopen, can you try 6.8 to verify? 
Comment 5 Sergey Petrov 2009-10-06 13:25:19 UTC
I mean 8.4-701 in gf environment, but nb still use 8.3-603. so it may work with 8.3-603 in both places.
Comment 6 gholmer 2009-10-13 14:33:10 UTC
I still see the same behavior with build 200910100201 (just like the screenshot I posted).
Comment 7 Sergey Petrov 2009-10-13 17:15:39 UTC
ok, thanks,
have you tried newer driver?
can you provide information regarding your database and you settings in glassfish resources? (may be all steps to create
resource on gf side).
I will try again later too.
Comment 8 PeteX 2011-05-28 16:47:13 UTC
I am still seeing this problem with Netbeans 7.0 and Glassfish 3.1.  I tried updating the JDBC driver to the latest version (9.0-801.jdbc4) because of comment #7, but this made no difference.

I saw the problem after following essentially the same steps as the original poster, except:

- I used the version of Glassfish that is bundled with Netbeans.
- I created a Java EE 6 web project rather than an enterprise project.

I'm not sure what specific information comment #7 is requesting, but basically I created the resource through the Glassfish web admin system.  I created a JDBC resource jdbc/myresource pointing to MyResourcePool and with no additional properties.  The pool's properties are all defaults except:

Resource Type: javax.sql.DataSource
Datasource Classname: org.postgresql.ds.PGSimpleDataSource

I also set the User, DatabaseName, Password, and ServerName properties.

(I tried setting the resource type to other things, but that didn't help.)
Comment 9 Sergey Petrov 2011-05-30 08:51:40 UTC
Is "org.postgresql.ds.PGSimpleDataSource" present in supplied driver?
can you attach message.log?
Comment 10 PeteX 2011-05-31 15:08:21 UTC
Yes "org.postgresql.ds.PGSimpleDataSource" is present in postgresql-8.3-603.jdbc3.jar.  I'll attach message.log.

Thanks for your help.
Comment 11 PeteX 2011-05-31 15:11:23 UTC
Created attachment 108627 [details]
messages.log

This messages.log was generated when I:

1.  opened the IDE,
2.  opened the Java EE project that was showing the problem before,
3.  attempted to add entity classes from the database, causing the bug to manifest, and
4.  closed the project and the IDE.
Comment 12 Sergey Petrov 2011-05-31 15:39:08 UTC
ok, looks like datasource url either isn't configured properly or can't be calculated or just ide can't calculate and it's an issue
as there is [glassfish-javaee]: Unable to compute database vendor name for datasource url.
and it's likely have null: in url, as a woraround it may work to add full datasource url to db resources configuration on gf side.
also as this is a warning from gf module, cc vkraemer@netbeans.org
Comment 13 PeteX 2011-06-02 21:39:40 UTC
I added a new property called URL, with value jdbc:postgresql:postgres.  When I did that, the problem went away.  Thanks!

(IMHO this is still a bug that should be fixed, but this work-around makes it much less of a problem for me personally.)
Comment 14 gholmer 2013-09-13 15:03:14 UTC
What further information is needed for this issue?
Comment 15 Sergey Petrov 2013-09-13 15:23:38 UTC
please provide message.log if possible, and list of all propertied in datasource configuration, except password
Comment 16 gholmer 2013-09-13 16:25:09 UTC
When trying to reproduce it again, I was able to make it work by adding the URL parameter. I suppose I hadn't restarted either NetBeans or GlassFish when I tried that a few minutes ago.

Is there any way to let the user know that this property must be added? The message "The name of the driver class for the datasource is missing" doesn't give any idea of what needs to be done to make it work.

This is what I have (the URL parameter was added manually):

    <jdbc-connection-pool datasource-classname="org.postgresql.ds.PGPoolingDataSource" res-type="javax.sql.DataSource" name="hendrix">
      <property name="User" value="cenbe"></property>
      <property name="DatabaseName" value="hendrix"></property>
      <property name="LogLevel" value="0"></property>
      <property name="Password" value="********"></property>
      <property name="Ssl" value="false"></property>
      <property name="ServerName" value="localhost"></property>
      <property name="ProtocolVersion" value="0"></property>
      <property name="MaxConnections" value="0"></property>
      <property name="InitialConnections" value="0"></property>
      <property name="TcpKeepAlive" value="false"></property>
      <property name="SocketTimeout" value="0"></property>
      <property name="PortNumber" value="5432"></property>
      <property name="LoginTimeout" value="0"></property>
      <property name="UnknownLength" value="2147483647"></property>
      <property name="PrepareThreshold" value="5"></property>
      <property name="URL" value="jdbc:postgresql://localhost:5432/hendrix"></property>
    </jdbc-connection-pool>
    <jdbc-resource pool-name="hendrix" jndi-name="jdbc/hendrix"></jdbc-resource>

I've also attached a NetBeans log file generated during a failed attempt to create the entity classes (without the URL property in the GlassFish connection pool).
Comment 17 gholmer 2013-09-13 16:25:59 UTC
Created attachment 140059 [details]
NetBeans log file
Comment 18 Sergey Petrov 2013-09-13 18:27:55 UTC
yes, message need to be changed, I'll reevaluate the issue a bit later.
url is just another way to specify datasource, nb can handle it two ways.
Comment 19 Sergey Petrov 2013-10-08 05:37:05 UTC
some wizards should already contain expected url, some other messages like jpql editor may be another issue but with the same user side solution.
for example for jpql message can be changed to
"You need to register database connection on
Services tab (expected url: {value}) or add URL property to your datasource with already registered jdbc url)"

driver message is a bit anbother
Comment 20 Sergey Petrov 2013-12-25 09:41:27 UTC
org.netbeans.modules.glassfish.javaee.db.DbUtil may be more smart in url contruction for postgre etc. currently if tries to create missed url in case of derby only. but in fact persistence need more smart message and it's nice to have a better hint, as server plugin may always miss support for some db vendor and in this case fallback to url property should be required.
Comment 21 Sergey Petrov 2013-12-26 12:42:42 UTC
 org.postgresql.ds.PGPoolingDataSour is recognized now and may be used with gf, I need more details for other cases, and may be filed as separate issues,
I hope

    <jdbc-connection-pool datasource-classname="org.postgresql.ds.PGPoolingDataSource" res-type="javax.sql.DataSource" name="hendrix">
      <property name="User" value="cenbe"></property>
      <property name="DatabaseName" value="hendrix"></property>
      <property name="LogLevel" value="0"></property>
      <property name="Password" value="********"></property>
      <property name="Ssl" value="false"></property>
      <property name="ServerName" value="localhost"></property>
      <property name="ProtocolVersion" value="0"></property>
      <property name="MaxConnections" value="0"></property>
      <property name="InitialConnections" value="0"></property>
      <property name="TcpKeepAlive" value="false"></property>
      <property name="SocketTimeout" value="0"></property>
      <property name="PortNumber" value="5432"></property>
      <property name="LoginTimeout" value="0"></property>
      <property name="UnknownLength" value="2147483647"></property>
      <property name="PrepareThreshold" value="5"></property>
      <property name="URL" value="jdbc:postgresql://localhost:5432/hendrix"></property>
    </jdbc-connection-pool>
    <jdbc-resource pool-name="hendrix" jndi-name="jdbc/hendrix"></jdbc-resource>

should work now as I see proper url in tooltip, feel free to reopen if this configuration will not work.

I decide to avoid general solution for now and support what should be supported in my opinion instead.
Comment 22 Quality Engineering 2013-12-27 02:44:54 UTC
Integrated into 'main-silver', will be available in build *201312270002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/4b4376b25aa4
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: #164814 add "org.postgresql.ds.PGPoolingDataSource" as recognized by gf plugin