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 209073 - "entity classes from data source" won't recognize data source
Summary: "entity classes from data source" won't recognize data source
Status: RESOLVED FIXED
Alias: None
Product: serverplugins
Classification: Unclassified
Component: GlassFish (show other bugs)
Version: 7.3
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Assignee: Vince Kraemer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-01 21:36 UTC by gholmer
Modified: 2016-05-09 14:50 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
screen shot (59.41 KB, image/png)
2012-03-06 20:26 UTC, gholmer
Details
screen shot (12.57 KB, image/png)
2012-03-20 18:58 UTC, gholmer
Details
Driver Class Error (202.79 KB, image/jpeg)
2013-11-21 12:52 UTC, strayan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gholmer 2012-03-01 21:36:58 UTC
I'm trying to create entity classes from an existing Postgres database,
using NetBeans 7.1.1. There is a data connection pool and JDBC resource
set up in GlassFish 3.1, both of which NetBeans can see. There's also a
database connection set up in NetBeans, in the Database Explorer.

I start by right-clicking project and selecting New / Persistence / Entity Classes from Database. Next, the dialog asks me to select a data source from a dropdown; the one I'm looking for shows up. But immediately I click it, the new connection dialog comes up, and if I try to complete it, I get "Unable to add connection. Connection already exists."

This happens whether or not I have a PU set up.
Comment 1 Sergey Petrov 2012-03-02 06:46:02 UTC
this issue should depend on a way to setup connection pool/datasource, what properties are set (url/papssword etc.) can you provide more steps(no need in password value, but need to know if it's set) also may depend on special characters in names/password (out of ASCII range)
Comment 2 gholmer 2012-03-06 20:25:48 UTC
1) Create database in Postgres, create connection pool in GlassFish. No non-ASCII characters or embedded spaces in any names or passwords.
2) Ping connection in GlassFish to verify it works.
3) Create resource "jdbc/test" in GlassFish.
4) Create new web app in NetBeans.
5) Right-click project, select "New / Entity Classes from Database".
6) Select resource created in step 3 from dropdown and click.
7) Immediately appears "New Connection Wizard." with message "Driver file is missing". Driver used by GlassFish is postgresql-8.4-702.jdbc4.jar.
8) Hovering over connection while selecting gives the attached screenshot (password is blacked out). Note the "null" in this screenshot.
Comment 3 gholmer 2012-03-06 20:26:18 UTC
Created attachment 116411 [details]
screen shot
Comment 4 Sergey Petrov 2012-03-07 11:08:59 UTC
what properties are set for connection pool?
null may means some are not recognized/ found by nb.
Comment 5 gholmer 2012-03-07 14:23:08 UTC
from GlassFish's domain.xml (password redacted):

<jdbc-connection-pool driver-classname="" datasource-classname="org.postgresql.ds.PGSimpleDataSource" res-type="javax.sql.DataSource" description="" name="test">
  <property name="DatabaseName" value="test"></property>
  <property name="User" value="glennh"></property>
  <property name="Password" value="********"></property>
  <property name="ServerName" value="localhost"></property>
  <property name="Ssl" value="false"></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="PrepareThreshold" value="5"></property>
  <property name="UnknownLength" value="2147483647"></property>
</jdbc-connection-pool>

<jdbc-resource pool-name="test" description="" jndi-name="jdbc/test"></jdbc-resource>
Comment 6 gholmer 2012-03-20 18:57:39 UTC
I also notice that NetBeans is creating some data sources in GlassFish that I didn't put there. See screen shot (the ones with the long names). Is there any other information I can provide?
Comment 7 gholmer 2012-03-20 18:58:29 UTC
Created attachment 116942 [details]
screen shot

screen shot showing NetBeans-generated data sources
Comment 8 Sergey Petrov 2012-03-20 19:37:09 UTC
What connections do you mean from your screenshot? Anyway I don't see it as related.
Can you try to add url property for your connection pool?
Comment 9 Sergey Petrov 2012-03-23 13:26:08 UTC
according to my investigation, URL isn't required but capitalization for "ServerName" matter, it should be "serverName", may be nb should allow different capitalization but it's "serverName" for default sample pool, and it may fail in some other place too. The issue if half misconfiguration issue but nb also shouldn't show configuration dialog if can't configure in real.
misconfiguration may not be an issue in 7.2 as after change for property key to"ServerName" for jdbc/sample I just don't see it in datasources list any more.
also if connection pool is created from ide, "serverName" is used (or should be used)
Comment 10 Sergey Petrov 2012-03-23 13:32:47 UTC
Vince, can you review? proposed patch:
# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- Базовая редакция (BASE)
+++ Локально измененный (на основе LOCAL)
@@ -107,6 +107,17 @@
         if(driverClassName.indexOf("pointbase") != -1){
             url = poolValues.get(__DatabaseName);
         }
+
+        if (serverName == null) {
+            for(String key : poolValues.keySet()){
+                if(__ServerName.equalsIgnoreCase(key)){
+                    serverName = poolValues.get(key);
+                    break;
+                }
+            }
+            poolValues.put(__ServerName, serverName);
+        }        
+        
         if (urlValue == null || urlValue.equals("")) { //NOI18N
             if (driverClassName.indexOf("derby") != -1) {
                 if (serverName != null) {
Comment 11 Petr Jiricka 2012-03-28 08:02:12 UTC
Cc'ing also Tomas Kraus.
Comment 12 steve-fresno 2012-04-04 15:55:07 UTC
I have the same problem, but with datasources connecting to an Oracle database. I have found that changing the case of the initial character of the datasource name does not help me, unless I am misunderstanding Sergey's suggested work-around. I have a jdbc resource named jdbc/FisDbDs which I renamed to jdbc/fisDbDs which is using a pool that was named Fis_Pool and is now named fis_pool. When I go back to the Netbeans 7.1.1 New Entity Classes from Database wizard and select the jdbc/fisDbDs datasource it takes me to the New Connection Wizard and then gives me the message "Unable to add connection. Connection already exists."
Comment 13 Sergey Petrov 2012-04-04 20:12:44 UTC
properties values character case doesn't matter, it just should match in any places, but properties keys case matter, you need to use "serverName" key instead of "ServerName" for example.
Comment 14 Wotlankor 2012-06-29 11:56:44 UTC
I had the same problem.

It seems the problem is related to the SQL server. You likely have had a database before that has had the name "test".

After hours of trial and error I simply deleted the old database and created a new one with a new name and imported tables.

I got the "avaliable tables" at once.
Comment 15 Wotlankor 2012-06-29 12:11:47 UTC
Remember to set up the new connection/Pool in Glassfish so it matches the new server name.
Comment 16 TomasKraus 2012-11-23 16:13:17 UTC
NetBeans web-main:
------------------
changeset:   240443:e9d8b77af0fd
summary:     #209073 - Search for server name key should be case insensitive

Added change suggested by Sergey.
Comment 17 Quality Engineering 2012-11-25 03:09:04 UTC
Integrated into 'main-golden', will be available in build *201211250002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/e9d8b77af0fd
User: Tomas Kraus <TomasKraus@netbeans.org>
Log: #209073 - Search for server name key should be case insensitive
Comment 18 TomasKraus 2012-11-26 15:45:26 UTC
Please can you test last nightly build to see if it works now?
Comment 19 gholmer 2013-03-08 23:12:04 UTC
Still broken in 7.3 final, as in original description and comment #2. "RESTful web services from database" behaves the same way.
Comment 20 gholmer 2013-03-08 23:18:08 UTC
No, actually I am not seeing "Driver file is missing" as in comment #2. But I do see "Connection already exists" and can't proceed further.
Comment 21 Sergey Petrov 2013-03-09 06:48:30 UTC
it may mean another issue,
it looks I need a way to show  what connection url is expected for persistence features, so user can create the same in new connection setup.
do you have any connections already registered?
Comment 22 docwalter 2013-03-28 20:35:07 UTC
I had exactly the same problem and solved it by changing the property key names of the following JDBC connection pool properties in GlassFish, so that they start with lowercase letters: "ServerName", "DatabaseName", "User", "Password", "PortNumber". The other properties remained unmodified.

Immediately after changing them to "serverName", "databaseName", "user", "password" and "portNumber", I could create the entity classes as intended.
Comment 23 Sergey Petrov 2013-03-29 04:41:47 UTC
I propose to close this one as fixed as it contain multiple problems when each issue should contain one only. And some initial problem isn't reproducible with latest, when others may need to be filed as new issues. Also latest builds should contain hint on expected connection url.
Comment 24 TomasKraus 2013-03-29 19:20:04 UTC
OK, I'm closing this bug as resoved.
Comment 25 Sergey Petrov 2013-04-01 06:21:38 UTC
this one issue cover unrecognized connection in case of different cases for 'ServerName' property.
any other issue with 'unrecognized datasources' etc. should be filed as new issue with as most details as possible, at least similar details to provided above for this issue.
Comment 26 javapaladin 2013-04-02 17:37:47 UTC
Just a note that I was experiencing this issue too but found that in my JDBC connection pool entry in Glassfish Admin (a MySQL connection), I had accidentally used "username" instead of "user" as an additional property.  The connection pool was working fine but I was unable to create an entity class from this data source in Netbeans.  After renaming "username" to "user", everything worked as expected.
Comment 27 Sergey Petrov 2013-04-02 18:50:10 UTC
I suppose if gf works fine with both user and username but netbeans plugin doesn't  work with username it may be filed as an issue against serverplugins/gf3 category. All these  issue will have the same result in entities from db wizard but are different issues in my opinion.
Comment 28 strayan 2013-11-21 12:52:56 UTC
Created attachment 142442 [details]
Driver Class Error
Comment 29 strayan 2013-11-21 12:55:04 UTC
Product Version: NetBeans IDE 7.4 (Build 201310111528)
Java: 1.7.0_45; Java HotSpot(TM) 64-Bit Server VM 24.45-b08
Runtime: Java(TM) SE Runtime Environment 1.7.0_45-b18
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
User directory: C:\Users\krithu\AppData\Roaming\NetBeans\7.4
Cache directory: C:\Users\krithu\AppData\Local\NetBeans\Cache\7.4


When following Step 2) of Section "Generating Entity Classes and RESTful Services" in the tutorial https://netbeans.org/kb/70/websvc/rest.html


Getting "Driver Class Error" as shown in attachment
Comment 30 Sergey Petrov 2013-11-21 12:59:30 UTC
How it's related to reopened issue and why it's p1?
Comment 31 btavares 2016-05-09 14:50:54 UTC
I was getting the same error on NetBeans 8.1, Glassfish 4.1 and PostgreSQL. 

It was only resolved when I added the url property in glassfish pool in the form:

"jdbc:postgresql://[serverName]:[portNumber]/[databaseName]"

without this property it never works.