Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 88871 - Cannot easily change JNDI resource name
Cannot easily change JNDI resource name
Status: RESOLVED FIXED
Product: obsolete
Classification: Unclassified
Component: visualweb
5.x
All All
: P2 (vote)
: 6.x
Assigned To: _ jimdavidson
issues@obsolete
http://wiki.netbeans.org/wiki/view/Da...
:
: 94728 (view as bug list)
Depends on: 113051
Blocks: 90450
  Show dependency treegraph
 
Reported: 2006-11-07 22:17 UTC by korb
Modified: 2007-08-20 02:26 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
:


Attachments

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
"jdbc/dataSource".

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 SessionBean1.java and rename the data
source name in the _init() method

   e.g. edit
tripRowSet.setDataSourceName("java:comp/env/jdbc/cpsDataSource");

3) open the setup/jdbc_dataSource.sun-resource file and change the JNDI
setting
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
com.sun.data.provider.impl.CachedRowSetDataProvider.getMetaData(CachedRowSetDataProvider.java:1320)
  at
com.sun.data.provider.impl.CachedRowSetDataProvider.getFieldKeys(CachedRowSetDataProvider.java:489)
  at
com.sun.data.provider.impl.CachedRowSetDataProvider.getFieldKeyInternal(CachedRowSetDataProvider.java:467)
  at
com.sun.data.provider.impl.CachedRowSetDataProvider.getFieldKey(CachedRowSetDataProvider.java:439)
  at
com.sun.rave.web.ui.faces.DataProviderPropertyResolver$SelectItemsData.getValue(DataProviderPropertyResolver.java:511)
  at
com.sun.rave.web.ui.faces.DataProviderPropertyResolver$SelectItemsData.getSelectItems(DataProviderPropertyResolver.java:636)
  at
com.sun.rave.web.ui.faces.DataProviderPropertyResolver.getValue(DataProviderPropertyResolver.java:146)
  at
com.sun.faces.el.PropertyResolverChainWrapper.getValue(PropertyResolverChainWrapper.java:75)
  at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:143)
  at
com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:62)
  at com.sun.el.parser.AstValue.getValue(AstValue.java:117)
  at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
  at
com.sun.faces.application.ValueBindingValueExpressionAdapter.getValue(ValueBindingValueExpressionAdapter.java:102)
  at
com.sun.rave.web.ui.dt.renderer.SelectorDesignTimeRenderer.encodeBegin(SelectorDesignTimeRenderer.java:105)
  at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:810)
  at
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:463)
  at
com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:253)
  at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:828)
  at
com.sun.rave.web.ui.util.RenderingUtilities.renderComponent(RenderingUtilities.java:80)
  at
com.sun.rave.web.ui.renderer.AbstractRenderer.encodeChildren(AbstractRenderer.java:194)
  at
com.sun.rave.web.ui.dt.renderer.AbstractDesignTimeRenderer.encodeChildren(AbstractDesignTimeRenderer.java:44)
  at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:828)
  at com.sun.rave.insync.faces.FacesPageUnit.renderBean(FacesPageUnit.java:1263)
  at com.sun.rave.insync.faces.FacesPageUnit.renderNode(FacesPageUnit.java:1482)
  at com.sun.rave.insync.faces.FacesPageUnit.renderBean(FacesPageUnit.java:1296)
  at com.sun.rave.insync.faces.FacesPageUnit.renderNode(FacesPageUnit.java:1482)
  at com.sun.rave.insync.faces.FacesPageUnit.renderBean(FacesPageUnit.java:1296)
  at com.sun.rave.insync.faces.FacesPageUnit.renderNode(FacesPageUnit.java:1482)
  at com.sun.rave.insync.faces.FacesPageUnit.renderBean(FacesPageUnit.java:1296)
  at com.sun.rave.insync.faces.FacesPageUnit.renderNode(FacesPageUnit.java:1482)
  at com.sun.rave.insync.faces.FacesPageUnit.renderBean(FacesPageUnit.java:1296)
  at
com.sun.rave.insync.faces.FacesPageUnit.getFacesRenderTree(FacesPageUnit.java:1066)
  at com.sun.rave.insync.faces.FacesPageUnit.renderHtml(FacesPageUnit.java:1604)
  at com.sun.rave.insync.models.FacesModel.getHtmlDomFragment(FacesModel.java:1502)
  at com.sun.rave.insync.models.FacesModel.findHtmlBody(FacesModel.java:1526)
  at com.sun.rave.insync.models.FacesModel.getHtmlBody(FacesModel.java:1514)
  at com.sun.rave.designer.jsf.JsfForm.getHtmlBody(JsfForm.java:308)
  at com.sun.rave.designer.WebForm.getHtmlBody(WebForm.java:749)
  at com.sun.rave.designer.DesignerPaneUI.resetPageBox(DesignerPaneUI.java:582)
  at com.sun.rave.designer.DesignerPaneUI.installUI(DesignerPaneUI.java:743)
  at javax.swing.JComponent.setUI(JComponent.java:652)
  at com.sun.rave.designer.DesignerPane.updateUI(DesignerPane.java:184)
  at com.sun.rave.designer.DesignerPane.init(DesignerPane.java:156)
  at com.sun.rave.designer.DesignerPane.<init>(DesignerPane.java:130)
  at
com.sun.rave.designer.DesignerTopComp.createDesignerPane(DesignerTopComp.java:824)
  at com.sun.rave.designer.DesignerTopComp.componentOpened(DesignerTopComp.java:230)
  at
org.netbeans.core.multiview.MultiViewPeer.showCurrentElement(MultiViewPeer.java:256)
  at
org.netbeans.core.multiview.MultiViewPeer.peerComponentOpened(MultiViewPeer.java:211)
  at
org.netbeans.core.multiview.MultiViewCloneableTopComponent.componentOpened(MultiViewCloneableTopComponent.java:133)
  at org.openide.windows.WindowManager.componentOpenNotify(WindowManager.java:273)
  at
org.netbeans.core.windows.WindowManagerImpl.notifyTopComponentOpened(WindowManagerImpl.java:902)
  at org.netbeans.core.windows.Central.addModeOpenedTopComponent(Central.java:590)
  at org.netbeans.core.windows.ModeImpl.addOpenedTopComponent(ModeImpl.java:255)
  at
org.netbeans.core.windows.PersistenceHandler.initModeFromConfig(PersistenceHandler.java:323)
  at org.netbeans.core.windows.PersistenceHandler.load(PersistenceHandler.java:158)
  at org.netbeans.core.windows.WindowSystemImpl.load(WindowSystemImpl.java:45)
  at org.netbeans.core.NonGui$3.run(NonGui.java:224)
  at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
  at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
  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.sql.SQLException: JdbcRowSetXImpl (connect): (JNDI) Unable to
connect: java:comp/env/jdbc/cpsDataSource
  at com.sun.sql.rowset.CachedRowSetXImpl.getConnection(CachedRowSetXImpl.java:4167)
  at com.sun.sql.rowset.CachedRowSetXImpl.getMetaData(CachedRowSetXImpl.java:2337)
  at
com.sun.data.provider.impl.CachedRowSetDataProvider.getMetaData(CachedRowSetDataProvider.java:1318)
  ... 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

Thanks
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 SessionBean1.java 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"/>
</object>

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

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

- 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: 
http://wiki.netbeans.info/wiki/view/VwpFAQJndi
Comment 7 John Baker 2007-01-24 18:19:14 UTC
So as not to leave any info out, more discussion here:
http://www.nabble.com/Data-source-name-references-don%27t-behave-in-VWP-tf2821303.html#a7879020
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
M10

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
datasources.

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).


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo