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 77312 - OOME while reading the schema from an Oracle Database
Summary: OOME while reading the schema from an Oracle Database
Status: RESOLVED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: DB schema (show other bugs)
Version: 5.x
Hardware: PC Windows XP
: P3 blocker (vote)
Assignee: Andrei Badea
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-02 14:28 UTC by gatep5
Modified: 2006-07-24 14:13 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Screenshot trying to connected to an Oracle Express (XE) database (59.10 KB, image/jpeg)
2006-06-04 22:20 UTC, gatep5
Details
dbschema module passing true for approximate (572.48 KB, application/octet-stream)
2006-07-07 11:36 UTC, Andrei Badea
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gatep5 2006-06-02 14:28:40 UTC
Using:
 Netbeans version 5.5 daily build June 1, 2006
 Oracle 10.2.0.1 database
 Oracle JDBC ojdbc14.jar thin driver

After adding a new Oracle JDBC datasource and trying to create a new entity
class from I get as far as selecting the Data Source... inputting my username
and password... and them making sure that the correct schema is chosen from the
Advanced tab.  The next dialogue box say "Retrieving the database schema" but
this process eventually times out with a Java Heap Space error.  I have not
tried the Netbeans 5.5 beta version with this senario.  List below is the stack
trace from the error:

java.lang.RuntimeException: Java heap space
	at
org.netbeans.modules.j2ee.persistence.util.EventRequestProcessor.invokeImpl(EventRequestProcessor.java:117)
	at
org.netbeans.modules.j2ee.persistence.util.EventRequestProcessor.invoke(EventRequestProcessor.java:74)
	at
org.netbeans.modules.j2ee.persistence.wizard.fromdb.DBSchemaManager.getSchemaElement(DBSchemaManager.java:138)
	at
org.netbeans.modules.j2ee.persistence.wizard.fromdb.DatabaseTablesPanel.updateSourceSchema(DatabaseTablesPanel.java:180)
	at
org.netbeans.modules.j2ee.persistence.wizard.fromdb.DatabaseTablesPanel.datasourceComboBoxActionPerformed(DatabaseTablesPanel.java:514)
	at
org.netbeans.modules.j2ee.persistence.wizard.fromdb.DatabaseTablesPanel.access$300(DatabaseTablesPanel.java:55)
	at
org.netbeans.modules.j2ee.persistence.wizard.fromdb.DatabaseTablesPanel$3.actionPerformed(DatabaseTablesPanel.java:296)
	at javax.swing.JComboBox.fireActionEvent(JComboBox.java:1197)
	at javax.swing.JComboBox.setSelectedItem(JComboBox.java:561)
	at javax.swing.JComboBox.setSelectedIndex(JComboBox.java:597)
	at
javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(BasicComboPopup.java:808)
	at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:232)
	at java.awt.Component.processMouseEvent(Component.java:5488)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
	at
javax.swing.plaf.basic.BasicComboPopup$1.processMouseEvent(BasicComboPopup.java:476)
	at java.awt.Component.processEvent(Component.java:5253)
	at java.awt.Container.processEvent(Container.java:1966)
	at java.awt.Component.dispatchEventImpl(Component.java:3955)
	at java.awt.Container.dispatchEventImpl(Container.java:2024)
	at java.awt.Component.dispatchEvent(Component.java:3803)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
	at java.awt.Container.dispatchEventImpl(Container.java:2010)
	at java.awt.Window.dispatchEventImpl(Window.java:1774)
	at java.awt.Component.dispatchEvent(Component.java:3803)
[catch] at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
	at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
	at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
	at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:153)
	at java.awt.Dialog$1.run(Dialog.java:517)
	at java.awt.Dialog$2.run(Dialog.java:545)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.awt.Dialog.show(Dialog.java:543)
	at org.netbeans.core.windows.services.NbPresenter.superShow(NbPresenter.java:810)
	at org.netbeans.core.windows.services.NbPresenter.doShow(NbPresenter.java:853)
	at org.netbeans.core.windows.services.NbPresenter.run(NbPresenter.java:841)
	at org.openide.util.Mutex.doEventAccess(Mutex.java:1172)
	at org.openide.util.Mutex.readAccess(Mutex.java:209)
	at org.netbeans.core.windows.services.NbPresenter.show(NbPresenter.java:826)
	at java.awt.Component.show(Component.java:1300)
	at java.awt.Component.setVisible(Component.java:1253)
	at org.openide.loaders.TemplateWizard.instantiateImpl(TemplateWizard.java:461)
	at org.openide.loaders.TemplateWizard.instantiate(TemplateWizard.java:346)
	at org.netbeans.modules.project.ui.actions.NewFile.doPerform(NewFile.java:117)
	at org.netbeans.modules.project.ui.actions.NewFile.access$200(NewFile.java:52)
	at
org.netbeans.modules.project.ui.actions.NewFile$PopupListener.actionPerformed(NewFile.java:311)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
	at javax.swing.AbstractButton.doClick(AbstractButton.java:302)
	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1000)
	at
javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1041)
	at java.awt.Component.processMouseEvent(Component.java:5488)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
	at java.awt.Component.processEvent(Component.java:5253)
	at java.awt.Container.processEvent(Container.java:1966)
	at java.awt.Component.dispatchEventImpl(Component.java:3955)
	at java.awt.Container.dispatchEventImpl(Container.java:2024)
	at java.awt.Component.dispatchEvent(Component.java:3803)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
	at java.awt.Container.dispatchEventImpl(Container.java:2010)
	at java.awt.Window.dispatchEventImpl(Window.java:1774)
	at java.awt.Component.dispatchEvent(Component.java:3803)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
	at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
	at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Caused by: java.lang.OutOfMemoryError: Java heap space

Your help is greatly appreciated!
Comment 1 Petr Blaha 2006-06-02 14:41:29 UTC
Move to correct component.
Comment 2 gatep5 2006-06-04 22:18:43 UTC
Tried connecting to an Oracle Express database using the same steps and it
returned a list of a bunch of tables all of which were grayed out.  If I can
figure out how, I will post the screenshot.
Comment 3 gatep5 2006-06-04 22:20:50 UTC
Created attachment 30776 [details]
Screenshot trying to connected to an Oracle Express (XE) database
Comment 4 perrych2 2006-06-30 12:14:30 UTC
The grayed out tables issue is a result of the schema capture's failure to
retrieve the primary keys for the tables which I too am experiencing.  I use
both  MySQL datasources and Oracle 10g, and the problem only occurs with Oracle
(using the same driver as listed in gatep5's original post).  This seems to be a
seperate issue from the original issue posted and should IMO have its own issue
number.
Comment 5 Andrei Badea 2006-06-30 19:25:47 UTC
Please try again with the latest daily build. More information will be displayed
in the "Retrieving the database schema" dialog -- the names of the tables and so
on. How many tables do you have in the database? How many of them are retrieved
when the exception occurs? What is your maximum heap size? Does increasing it help?
Comment 6 perrych2 2006-07-05 03:52:06 UTC
On the missing primary keys issue:  The problem is a permissions issue in a
round-a-bout fashion.  Even though you can get the primary keys from the JDBC
driver in Oracle via getPrimaryKeys, you must have the "ANALYZE ANY" permission
to call getIndexInfo on the DatabaseMetaData object.  Net beans uses the results
of getIndexInfo() to iterate through indexes looking for primary keys.  Because
it throws an exception listing the indexes without the "ANALYZE ANY" perm, it
never looks for the primary keys.  The work around is to ensure that the jdbc
connection account has the ANALYZE ANY permission.  IMO, this is an Oracle thin
JDBC bug as I cannot see any reason for escalating the user perms just to
enumerate the indices, but I'm no Oracle expert and that appears to be the way
it works.  Strangely granting the index permission on the table is insufficient.
Comment 7 Andrei Badea 2006-07-07 10:49:15 UTC
Thank you for the info. The foreign keys problem is also filed as issue 78614. I
tried reproducing the problem with the script attached with that issue. I
created a new user specifically for this and granted it only the CONNECT and
RESOURCE roles (I believe none of them includes ANALYZE ANY). Still, I wasn't
able to reproduce the issue.

However, "ANALYZE ALL" reminds me of an issue in the Database Explorer caused by
the Oracle driver trying to execute the ANALYZE TABLE statement when calling
getIndexInfo(). The issue was caused by passing false as the approximate
parameter of this method. It was fixed in the Database Explorer, but dbschema
still passes false. I will change it to true, let's see if it helps.
Comment 8 Andrei Badea 2006-07-07 11:34:02 UTC
Passing true instead of false for approximate.

Checking in src/org/netbeans/modules/dbschema/jdbcimpl/TableElementImpl.java;
/cvs/db/model/src/org/netbeans/modules/dbschema/jdbcimpl/TableElementImpl.java,v
 <--  TableElementImpl.java
new revision: 1.2.50.2; previous revision: 1.2.50.1
done
Comment 9 Andrei Badea 2006-07-07 11:36:25 UTC
Created attachment 31684 [details]
dbschema module passing true for approximate
Comment 10 Andrei Badea 2006-07-07 11:39:17 UTC
Since I don't know the date of the next daily build I attached the fixed
dbschema module. Please copy it to <netbeans>/enterprise3/modules and test.

perrych2: I took the liberty to add you to the CC so you can test it too if you
can. 

Thanks.
Comment 11 perrych2 2006-07-07 17:43:55 UTC
I gave the supplied jar a try and observed no change when the "ANALYZE ANY"
system privilege was removed.  The following code snippet comes from a test for
this issue (independant of netbeans):

boolean approximate = false;
boolean unique = false;
Connection conn = DriverManager.getConnection(connection, user, password);
DatabaseMetaData dmd = conn.getMetaData();
ResultSet indexrs =
dmd.getIndexInfo("","TESTSCHEMA","TESTTABLE",unique,approximate);

For any combination of values for approximate and unique where the user does not
have the "ANALYZE ANY" system privilege the following exception is thrown for
dmd.getIndexInfo:

java.sql.SQLException: ORA-01031: insufficient privileges

Interestingly though dmd.getPrimaryKeys, dmd.getImportedKeys, and
dmd.getExportedKeys do not throw an exception without the "ANALYZE ANY" system
privilege.  This is clearly a result of getIndexInfo() calling ANALYZE TABLE or
some such as you stated.  My guess is that it is because getIndexInfo includes
statistical information, where as the above 3 do not.  I am guessing from this
that there is no workaround for this that will result in a complete schema
implementation without granting "ANALYZE ANY" to the connection user.

Comment 12 gatep5 2006-07-12 21:20:47 UTC
The original problem that I described in this bug report seems to now be fixed
with the lastest daily build. I am able to see all the tables in my Oracle
database and successfully create the entity objects using the Netbeans wizard. 
Unfortunately, I do not know what really was changed inorder for this to be fixed.
Comment 13 Andrei Badea 2006-07-14 11:17:04 UTC
gatep5: just to be sure: do you mean the OutOfMemoryError by "original problem"
or the tables being grayed out?
Comment 14 gatep5 2006-07-21 20:49:14 UTC
This problem must have been user error in setting up the Oracle database.  I
have since tried the daily build from June 29, 2006 as well as Netbeans Beta 1
and did not have any problems connecting and retreiving the database schema
(There were no OutOfMemory errors.)  I have tried builds with dates later than
that and they seem to work as well.  I realize that the grayed out tables that I
showed from the screen shot posted are grayed out because they don't have
primary keys set, so I don't consider that an issue that needs to be fixed.  My
apologies for wasting your time.

As far as the other person that is CCed on this bug report, I have not tried or
experienced the problems that he/she has and cannot provide any useful feedback
for that issue.  
Comment 15 perrych2 2006-07-24 13:05:25 UTC
The issue that I experienced with not finding primary keys was in fact due to
the missing analyze any privilege.  I later found in the Sun Java Application
Server documentation a footnote that the Analyze Any privilege is required for
exactly the same reason.  While I disagree that this privilege should be
required, it really doesn't have anything to do with Netbeans and I wouldn't
consider it an NB bug.  The issue is resolved from my perspective.
Comment 16 Andrei Badea 2006-07-24 14:13:36 UTC
gatep5: good to hear, thanks. I take it there are no more problems from your
point of view (as far as this issue is concerned).

perrych2: I just (independently) also read in the docs of the Sun appserver that
the ANALYZE ANY privilege is needed for tables not in a schema owned by the user
connecting to the database. Is this your case? If yes then I can reproduce the
issue now. Actually, only when commenting out the fix of issue 56492, which
causes the missing indexes to be ignored, so the foreign keys are retrieved
correctly even if the "insufficient privileges" SQLException is thrown.

I guess this also fixes your use case. Note, however, that the fix of issue
56492 is not in beta 2.

Marking as fixed then.