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 117005 - AddDriverDialog NPE occurs if registering driver using a layer file
Summary: AddDriverDialog NPE occurs if registering driver using a layer file
Status: RESOLVED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: John Baker
URL:
Keywords:
Depends on:
Blocks: 116053
  Show dependency tree
 
Reported: 2007-09-28 04:29 UTC by John Baker
Modified: 2007-10-03 14:07 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
XML file which describes the driver in the module layer (1.31 KB, text/xml)
2007-09-28 04:32 UTC, John Baker
Details
diff of changes (1.44 KB, text/plain)
2007-09-28 04:38 UTC, John Baker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Baker 2007-09-28 04:29:49 UTC
Using the layer file approach to registering a driver almost works.
The driver gets added to the Services tab.  However, when choosing the Customize action, an NPE occurs.

I had created an "XML file which describes the driver in the module layer" attached.
The problem is the reference to the driver uses the jar protocol.
So, once inside the AddDriverDialog non-default ctr, the FileObject is an AbstractFileObject so, FileUtil.toFile(fo) is
null.

A suggested fix is to add the following condition to the non-default ctr .

else if (!fo.isData()) {
    // try/catch is required
    fileName = fo.getFileSystem().getDisplayName();
}

This will set filename to the absolute path of the driver jar file.

Attached will be a diff.
Comment 1 John Baker 2007-09-28 04:32:11 UTC
Created attachment 49718 [details]
XML file which describes the driver in the module layer
Comment 2 John Baker 2007-09-28 04:33:09 UTC
blocks 116053
Comment 3 John Baker 2007-09-28 04:38:53 UTC
Created attachment 49719 [details]
diff of changes
Comment 4 John Baker 2007-09-29 21:48:32 UTC
Fixed.  Unit tests ran and passing, the testComboboxWithConnections unit test could be updated.
Will file separate issue to track

Checking in db/src/org/netbeans/modules/db/explorer/dlg/AddDriverDialog.java;
/cvs/db/src/org/netbeans/modules/db/explorer/dlg/AddDriverDialog.java,v  <--  AddDriverDialog.java
new revision: 1.43; previous revision: 1.42
done
Comment 5 Andrei Badea 2007-10-03 14:07:42 UTC
Don't like the fix much. FileSystem.getDisplayName() is what the name suggests it is: a string to be shown in the UI.
There is no guarantee it will be the path of the JAR file.

Checking in src/org/netbeans/modules/db/explorer/dlg/AddDriverDialog.java;
/cvs/db/src/org/netbeans/modules/db/explorer/dlg/AddDriverDialog.java,v  <--  AddDriverDialog.java
new revision: 1.45; previous revision: 1.44
done