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.
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.
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)
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.
Created attachment 116411 [details] screen shot
what properties are set for connection pool? null may means some are not recognized/ found by nb.
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>
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?
Created attachment 116942 [details] screen shot screen shot showing NetBeans-generated data sources
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?
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)
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) {
Cc'ing also Tomas Kraus.
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."
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.
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.
Remember to set up the new connection/Pool in Glassfish so it matches the new server name.
NetBeans web-main: ------------------ changeset: 240443:e9d8b77af0fd summary: #209073 - Search for server name key should be case insensitive Added change suggested by Sergey.
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
Please can you test last nightly build to see if it works now?
Still broken in 7.3 final, as in original description and comment #2. "RESTful web services from database" behaves the same way.
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.
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?
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.
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.
OK, I'm closing this bug as resoved.
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.
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.
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.
Created attachment 142442 [details] Driver Class Error
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
How it's related to reopened issue and why it's p1?
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.