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.
Build: NetBeans IDE Dev (Build web-main-779-on-20140503) VM: Java HotSpot(TM) 64-Bit Server VM, 24.55-b03, Java(TM) SE Runtime Environment, 1.7.0_55-b13 OS: Mac OS X User Comments: pjiricka: RESTful services from database -> I chose the bundled Derby connection on the Database Tables panel. Stacktrace: java.lang.NullPointerException at org.netbeans.modules.db.explorer.action.ConnectAction$ConnectionDialogDisplayer.supportsConnectWithoutUsername(ConnectAction.java:393) at org.netbeans.modules.db.explorer.action.ConnectAction$ConnectionDialogDisplayer.showDialog(ConnectAction.java:190) at org.netbeans.modules.db.explorer.DatabaseConnection$5.run(DatabaseConnection.java:1224) at org.openide.util.Mutex.doEvent(Mutex.java:1356) at org.openide.util.Mutex.readAccess(Mutex.java:355) at org.netbeans.modules.db.explorer.DatabaseConnection.showConnectionDialog(DatabaseConnection.java:1221)
Created attachment 147161 [details] stacktrace
Petre, are you able to reproduce? I was unsuccessful (on Windows). Changing TM to Next.
Hey Libor, I thing we are seeing the result of a broken connection definition. I'm in ConnectAction#supportsConnectWithoutUsername - dc can't be null, as this would have blown earlier (line 182, 180, 179) - JDBCDriver#getClassName can't be null (see protection in JDBCDriver#create) - so this leaves us with DatabaseConnection findJDBCDriver So findJDBCDriver has to be guarded: # This patch file was generated by NetBeans IDE # It uses platform neutral UTF-8 encoding and \n newlines. --- Base (BASE) +++ Locally Modified (Based On LOCAL) @@ -390,9 +390,14 @@ } private boolean supportsConnectWithoutUsername(DatabaseConnection dc) { - return dc.findJDBCDriver().getClassName().equals("org.sqlite.JDBC") || //NOI18N - dc.findJDBCDriver().getClassName().equals("org.h2.Driver"); //NOI18N + try { + return dc.findJDBCDriver().getClassName().equals("org.sqlite.JDBC") //NOI18N + || dc.findJDBCDriver().getClassName().equals("org.h2.Driver"); //NOI18N + } catch (NullPointerException ex) { + // Most probably findJDBCDriver failed to find a driver + return false; } } + } } Maybe DatabaseConnection should gain some documentation/beautification: # This patch file was generated by NetBeans IDE # It uses platform neutral UTF-8 encoding and \n newlines. --- Base (BASE) +++ Locally Modified (Based On LOCAL) @@ -263,24 +263,33 @@ setConnectionProperties(connectionProperties); } + /** + * Find a registered JDBC driver matching this connection. The function + * makes a best effort search, if at least a driver with a matching classname + * is present this function will succeed. If a driver with a matching name is + * present this will be returned. + * + * @return matching JDBC driver for connection or NULL if no match is found + */ public JDBCDriver findJDBCDriver() { JDBCDriver[] drvs = JDBCDriverManager.getDefault().getDrivers(drv); - if (drivers == null || ! Arrays.equals(drvs, drivers)) { + if (drivers == null || !Arrays.equals(drvs, drivers)) { drivers = drvs; - if (drvs.length <= 0) { - return null; - } + JDBCDriver useDriver = null; - JDBCDriver useDriver = drvs[0]; + if (drvs.length > 0) { + // Fallback - potentially false driver (by name), but at least matches requested class + useDriver = drvs[0]; for (int i = 0; i < drvs.length; i++) { if (drvs[i].getName().equals(getDriverName())) { useDriver = drvs[i]; break; } } - jdbcdrv = useDriver; + } + jdbcdrv = useDriver; } return jdbcdrv; }
Matthias, thank you for your patch. Applied - http://hg.netbeans.org/core-main/rev/1c5924828bf5
Integrated into 'main-silver', will be available in build *201407310738* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/1c5924828bf5 User: Libor Fischmeistr <lfischmeistr@netbeans.org> Log: #244350: NullPointerException at org.netbeans.modules.db.explorer.action.ConnectAction$ConnectionDialogDisplayer.supportsConnectWithoutUsername
*** Bug 243582 has been marked as a duplicate of this bug. ***