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

Summary: AddDriverDialog NPE occurs if registering driver using a layer file
Product: db Reporter: John Baker <jbaker>
Component: CodeAssignee: John Baker <jbaker>
Status: RESOLVED FIXED    
Severity: blocker CC: davidvc
Priority: P3    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Bug Depends on:    
Bug Blocks: 116053    
Attachments: XML file which describes the driver in the module layer
diff of changes

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