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.
There is a bug in SchemaElementImpl.checkReferences() that is affecting the appserver tests when run against mysql database. In the case of mysql database the schema name that is returned is null. The jdbc api documentation for DatabaseMetaData.getImportedKeys() states that the schemaName is allowed to be null. However, the code in checkReferences() is not prepared to handle this and is defined as: pkSchema = rs.getString("PKTABLE_SCHEM").trim(); //NOI18N fkSchema = rs.getString("FKTABLE_SCHEM").trim();//NOI18N This code throws a NPE and the schema is not being populated with the tables. This causes the deployment of the application to fail.
More info: Url to JDBC docs: <http://java.sun.com/j2se/1.4.2/docs/api/java/sql/DatabaseMetaData.html#getImportedKeys(java.lang.String,%20java.lang.String,%20java.lang.String)> The code swallows this exception by default, but is visible if you define a -D option to the application server of the form "netbeans.debug.exceptions = true". The code to refer to is com/sun/forte4j/modules/dbmodel/jdbcimpl/SchemaElementImpl.initTables(ConnectionProvider cp, LinkedList t, LinkedList v, boolean allTables) : } catch (Exception exc) { if (Boolean.getBoolean("netbeans.debug.exceptions")) // NOI18N exc.printStackTrace(); }
Fixed by testing for null before calling trim(). But is the trim() call really necessary? Note that when the schema is generated from netbeans (the if (bridge != null) statement on row 309 passes) the pkSchema and fkSchema are not trimmed. Checking in SchemaElementImpl.java; /cvs/db/model/src/org/netbeans/modules/dbschema/jdbcimpl/SchemaElementImpl.java,v <-- SchemaElementImpl.java new revision: 1.4; previous revision: 1.3 done
I filed this issue on behalf of 2 coworkers. Here is the response I got when asking your trim question: "The code doesn't trim when inside NB (bridge != null), and trim is harmless if there is nothing to trim. So unless they have all the tests that can proof stability, I will keep the trim." Thanks for the quick fix!
VERIFIED