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 88871 - Cannot easily change JNDI resource name
Summary: Cannot easily change JNDI resource name
Alias: None
Product: obsolete
Classification: Unclassified
Component: visualweb (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: _ jimdavidson
: 94728 (view as bug list)
Depends on: 113051
Blocks: 90450
  Show dependency tree
Reported: 2006-11-07 22:17 UTC by korb
Modified: 2007-08-20 02:26 UTC (History)
0 users

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description korb 2006-11-07 22:17:51 UTC
I posted the following message on the nbusers mailing list:

When I created my new VWP project, it created a default dataSource
resource-ref in my web.xml and sun-web.xml named "jdbc/dataSource". I
modified the sun-web.xml to map this to an pre-existing jndi-name of
"jdbc/cpsDataSource" which I use on my app server. At least once, NB/VWP
has modified sun-web.xml and reverted the jndi-name back to

What is the correct way using VWP to define more than one dataSource or
to rename the default dataSource created for me? Or is this
functionality not yet implemented?

I think it's fair to say that not every app I write will use the same
dataSource, and at the moment, VWP looks to be a one-trick pony.  ;-)

I then received the following response (from John Baker @ Sun):

VWP has hands tied for now on this one-trick Pony, unfortunately  :-( 

When choosing a name for the data source or renaming, make sure there is no
exising JNDI name created in the Application Server.

1) Close IDE
2) In a project's directory, edit and rename the data
source name in the _init() method

   e.g. edit

3) open the setup/jdbc_dataSource.sun-resource file and change the JNDI
4) Edit the web/WEB-INF/web.xml file and change the <res-ref-name> setting
5) Start IDE and deploy

I'd like to see a built-in means for making this change as this is something
that will be required quite often.
Comment 1 John Baker 2006-11-07 23:01:47 UTC
A change for the first release would require new architecuture and UI changes
and too late for this release of VWP.

To be resolved in the subsequent release.

Please let me know if the workaround provided solves this issue in the meantime
Comment 2 korb 2006-11-07 23:47:44 UTC
No, this work-around did not fix this. After making the specified changes and
restarting NB+VWP, the visual designer displayed a "Component Error" message
instead of the visual editor, and the following stack trace was shown:

java.lang.RuntimeException: java.sql.SQLException: JdbcRowSetXImpl (connect):
(JNDI) Unable to connect: java:comp/env/jdbc/cpsDataSource
  at javax.el.CompositeELResolver.getValue(
  at com.sun.el.parser.AstValue.getValue(
  at com.sun.el.ValueExpressionImpl.getValue(
  at javax.faces.component.UIComponentBase.encodeBegin(
  at javax.faces.component.UIComponentBase.encodeChildren(
  at javax.faces.component.UIComponentBase.encodeChildren(
  at com.sun.rave.insync.faces.FacesPageUnit.renderBean(
  at com.sun.rave.insync.faces.FacesPageUnit.renderNode(
  at com.sun.rave.insync.faces.FacesPageUnit.renderBean(
  at com.sun.rave.insync.faces.FacesPageUnit.renderNode(
  at com.sun.rave.insync.faces.FacesPageUnit.renderBean(
  at com.sun.rave.insync.faces.FacesPageUnit.renderNode(
  at com.sun.rave.insync.faces.FacesPageUnit.renderBean(
  at com.sun.rave.insync.faces.FacesPageUnit.renderNode(
  at com.sun.rave.insync.faces.FacesPageUnit.renderBean(
  at com.sun.rave.insync.faces.FacesPageUnit.renderHtml(
  at com.sun.rave.insync.models.FacesModel.getHtmlDomFragment(
  at com.sun.rave.insync.models.FacesModel.findHtmlBody(
  at com.sun.rave.insync.models.FacesModel.getHtmlBody(
  at com.sun.rave.designer.jsf.JsfForm.getHtmlBody(
  at com.sun.rave.designer.WebForm.getHtmlBody(
  at com.sun.rave.designer.DesignerPaneUI.resetPageBox(
  at com.sun.rave.designer.DesignerPaneUI.installUI(
  at javax.swing.JComponent.setUI(
  at com.sun.rave.designer.DesignerPane.updateUI(
  at com.sun.rave.designer.DesignerPane.init(
  at com.sun.rave.designer.DesignerPane.<init>(
  at com.sun.rave.designer.DesignerTopComp.componentOpened(
  at org.netbeans.core.NonGui$
  at java.awt.event.InvocationEvent.dispatch(
  at java.awt.EventQueue.dispatchEvent(
  at java.awt.EventDispatchThread.pumpEvents(
  at java.awt.EventDispatchThread.pumpEvents(
Caused by: java.sql.SQLException: JdbcRowSetXImpl (connect): (JNDI) Unable to
connect: java:comp/env/jdbc/cpsDataSource
  at com.sun.sql.rowset.CachedRowSetXImpl.getConnection(
  at com.sun.sql.rowset.CachedRowSetXImpl.getMetaData(
  ... 63 more

After switching back to the original states of each of these changed files, I
then changed the sun-web.xml (since I deploy this on a SJAS 8.2 instance) so
that the resource-ref still had the res-ref-name as jdbc/dataSource, but I
changed the jndi-name to jdbc/cpsDataSource then manually added this new JDBC
Resource via the AS admin console.
Comment 3 John Baker 2006-11-08 22:33:28 UTC
The workaround should work. Could you zip up a project (sans libraries)
and attach to the bug or email me directly

cfqa-testapps AT sun DOT com

Comment 4 korb 2006-11-09 17:17:27 UTC
In an attempt to get to the bottom of this, I did the following:

- New Project (named bug88871) with J2EE 1.4, source level 1.5, deploying to my
SJAS 8.2 instance
- Dropped a static text (title) component on Page1
- Dropped a drop-down list component on Page1
- Dragged the REQUESTOR table from my Oracle database in the Runtime->Databases
view and dropped it on my drop-down list
- Selected the Bind to Data... context menu item on my drop-down and verified
that it was bound to the fields I wanted
- Ran the project - new dataSource resource was created, app was deployed, and
it worked
- Went into the Runtime->Servers view and undeployed my app and deleted the
dataSource resource and its oracle-thinPool connection pool
- Shutdown the IDE
- Opened in TextPad and changed "dataSource" to
"demoDataSource" in the _init() method
- Opened jdbc_dataSource.sun-resource in TextPad and changed "dataSource" to
"demoDataSource" in the jdbc-resource tag
- Opened web.xml in TextPad and changed "dataSource" to "demoDataSource" in the
res-ref-name tag
- Restarted IDE, and it opened to my new project, Page1 in the visual editor,
and displayed the "Component Error" screen with a SQLException ("(JNDI) Unable
to connect: java:comp/env/jdbc/demoDataSource")

Poked around a bit more, and made some additional changes:

- Opened sun-web.xml in TextPad and changed "dataSource" to "demoDataSource" in
the res-ref-name and jndi-name tags
- Opened oracle-thinPool.sun-resource in TextPad and changed "oracle-thinPool"
to "demo-oracle-thinPool" in jdbc-connection-pool tag
- Opened jdbc_dataSource.sun-resource in TextPad and changed "oracle-thinPool"
to "demo-oracle-thinPool" in jdbc-resource tag

Found the following in ~/.netbeans/5.5/context.xml:

<object name="dataSource" class="com.sun.rave.sql.DesignTimeDataSource">
    <arg class="java.lang.Boolean" value="false"/>
    <arg class="java.lang.String"/>
    <arg class="java.lang.Boolean" value="true"/>
    <arg class="java.lang.String" value="oracle.jdbc.driver.OracleDriver"/>
    <arg class="java.lang.String" value="jdbc:oracle:thin:@app-ora008:1521:DBT1"/>
    <arg class="java.lang.String"/>
    <arg class="java.lang.String" value="mydb"/>
    <arg class="java.lang.String" value="A45909A45909A45909"/>

and in ~/.netbeans/5.5/var/attributes.xml:

<fileobject name="C:|src|bug88871|src|java|bug88871|">
    <attr name="datasource-names" stringvalue="java:comp/env/jdbc/dataSource"/>

- I changed both files to specify demoDataSource instead of dataSource, and
restarted the IDE - no component error this time!
- Ran the project, and the new connection pool (demo-oracle-thinPool) was
created as was the new JDBC resource (demoDataSource)

So, in addition to changing the files in the project itself as was originally
described, you must also update the context.xml and attributes.xml in the NB
user directory as these are IDE-wide settings, not specific to a single project.
Comment 5 John Baker 2006-11-14 20:04:05 UTC
Thanks for the additional information.
This will be added to the release notes - can't fix for FCS but will be on the
radar for the next release

Thank you for contributing to VWP TP
Comment 6 Joseph Silber 2006-11-24 10:01:01 UTC
This information has been added to the FAQ as well:
Comment 7 John Baker 2007-01-24 18:19:14 UTC
So as not to leave any info out, more discussion here:
Comment 8 John Baker 2007-02-08 01:58:44 UTC
This is a P2 task so raising the priority to keep in-sync
Comment 9 John Baker 2007-03-20 06:25:15 UTC
Data source name is more meaningful now.
[schema] + [database product name]

Planning on a feature so the user can change the name easily
Comment 10 John Baker 2007-03-27 03:21:11 UTC
Capability to rename a data source name will be postponed until at least

As of M8, data source name follows the format
[Schema][Database product Name]

My SQL connections do not require a schema so, the name format will
be [Database][Database product name]
Comment 11 John Baker 2007-03-27 03:23:21 UTC
*** Issue 94728 has been marked as a duplicate of this issue. ***
Comment 12 John Baker 2007-05-11 05:16:44 UTC
Apparently, "there is no possibility to invoke Choose Database dialog by some API"
So, rename will have to be done throught the property sheet
Comment 13 John Baker 2007-05-11 06:15:42 UTC
A better option would be to add a "Rename" action on the child data source node
and provide similar rename support as files
Comment 14 _ jimdavidson 2007-06-18 21:04:48 UTC
There are two ways to do this.

One way has been implemented in M10.  When the data source is first created, the user can specify the datasource name
(JNDI name) to use instead of the default name that the IDE generates.  The IDE prompts for a new name, in a dialog that
appears after a DB table is dropped onto the form.  The presence of the dialog is controlled by a system option, which
is turned off by default since most Visual Web users won't want to specify the name.

On that basis, I will mark this specific enhancement as fixed.

A better way would be to allow the datasource to be renamed by the user, after it is first created.  That is not
currently possible, because the underlying J2eeServer APIs do not provide support for either removing or renaming

I will open a separate P1 Enhancement for that additional functionality, to be addressed in a future release.
Comment 15 _ jimdavidson 2007-06-18 21:35:01 UTC
New Enhancement filed as #107082 (VisualWeb)/107081 (J2eeServer).