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 107653 - Unable to deploy web application after using Use Database action
Summary: Unable to deploy web application after using Use Database action
Status: NEW
Alias: None
Product: serverplugins
Classification: Unclassified
Component: Infrastructure (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Petr Hejl
Keywords: API
Depends on:
Reported: 2007-06-21 15:14 UTC by Michal Mocnak
Modified: 2010-05-13 09:12 UTC (History)
8 users (show)

See Also:
Exception Reporter:

working webapp (16.86 KB, application/octet-stream)
2007-06-21 17:48 UTC, Nitya Doraisamy

Note You need to log in before you can comment on or make changes to this bug.
Description Michal Mocnak 2007-06-21 15:14:51 UTC
Create a new web application. Create servlet inside. Call Use Database action. In the dialog set a new datasource
reference and choose server resource and turn on copy of this resource into project.

Problems: resource is not copied into project
          deploy is not functional due to missing reference

Error loading deployment descriptors for module [WebApplication1] -- This web app
[/Users/marigan/NetBeansProjects/WebApplication1/build/web] has no resource reference by the name of [TestReference]
Comment 1 Vince Kraemer 2007-06-21 15:19:09 UTC
what server are you deploying to?
Comment 2 Michal Mocnak 2007-06-21 15:28:43 UTC
glassfish v1 u1 p1 b02
Comment 3 Vince Kraemer 2007-06-21 15:41:18 UTC
this is actually a plugin code issue
Comment 4 Nitya Doraisamy 2007-06-21 17:46:21 UTC
Resource jndi name : jdbc/myDatasource, reference name: myDataSource

Deployment fails if the annotation is pointing to the jndiName of the resource. 
ie.@Resource(name = "jdbc/myDatasource")

Deployment is suceessful if annotation points to reference name of the resource
@Resource(name = "myDataSource")

Problem is that the api documentation indicates that 'name' in @Resource should be

Need to find out what the proper usage of this annotation is.
Comment 5 Nitya Doraisamy 2007-06-21 17:48:26 UTC
Created attachment 44209 [details]
working webapp
Comment 6 Nitya Doraisamy 2007-06-22 01:26:28 UTC
As per info from the server team, the @Resource name  should point to the resource-reference name if defined
and not to the jndi name of the resource. Attached is the response from server team. 
Who would be the contact on IDE to resolve this?

For Resource annoation, the "name" attribute is typically used for logical jndi name (reference name), and the
"mappedName" attribute is used for physical/global jndi name (which is product specific).
The sun-web.xml could be used to map a logical jndi name to a physical jndi name.
For the case where @Resource name attribute is pointed to "myDataSource", the sun-web.xml maps it to
"jdbc/myDataSource", so it works.
For the case where the name attribute is pointed to "jdbc/myDataSource", there is no corresponding entry for
"jdbc/myDataSource" in sun-web.xml, so this logical name will be used as physical jndi name. This part is ok. The
problem was caused by the sun-web.xml entry "myDataSource" -> "jdbc/myDataSource" as there is no Resource defined by
this reference name "myDataSource".  
Comment 7 nouar38 2007-06-22 10:14:01 UTC
added myself also to this issue.
In my case I can deploy a new web app having inside a new jdbc resource ( not used yet by any call), 
but without the resources.

Comment 8 nouar38 2007-06-22 10:22:06 UTC
On solaris-sparc IDE the web project is marked with a red "!", but not on the windows IDE
(nb 6.0 0619)
Comment 9 Nitya Doraisamy 2007-06-22 17:15:26 UTC
 Stephan, Could you redirect this to the correct component/contact who deals with Resource Injections. 
Comment 10 Nitya Doraisamy 2007-06-22 19:22:34 UTC
Also, copy resources to project checkbox does not do anything. Looked at the corresponding code and this functionality
has not been implemented and I don't think there is an api available for this.

It is still a TODO in org.netbeans.modules.j2ee.ejbcore.ui.logicalview.entres.SelectDatabasePanel
Comment 11 Vince Kraemer 2007-06-22 21:28:18 UTC
this has some more information that may be useful...

especially slide 13.

The Use Database action is writing incorrect code or asking plugins to write incorrect data into their XML files...

The root-cause of this issue should be fixed....
Comment 13 martin_adamek 2007-06-25 14:09:05 UTC
Sorry, forgot to reassign to me, so just adding to CC now.
Comment 14 Nitya Doraisamy 2007-06-25 17:59:00 UTC
Verified the @Resource injection. The resource-reference is being used and the project deploys successfully.

But the copy resources to project checkbox is still present, is editable and does nothing
if the user selects it. Shouldn't this action be disabled since it is not implemented. Not marking as verified as
this issue is still present.
Comment 15 martin_adamek 2007-06-25 18:44:21 UTC
I implemented and tested resource creation when checkbox is selected. Did you try it?
Comment 16 Nitya Doraisamy 2007-06-25 19:31:44 UTC
Yes. It does create the resource but this code flow is wrong. The checkbox indicates copy server resources
to project. I think the change you made calls the createDatasource api. This will result in the plugin
creating the resource in the IDE. They won't be an equivalent of the resources on server. eg. Appserver's 
JDBC resource refers to a JDBC Connection Pool and in the current flow, the datasource created by the plugin
might end up with a different JDBC Connection Pool.

The workaround would be for the plugin to explicitly check the server if any similar resources exist and copy 
the associated properties each time a createDatasource is called. This is an unnecessary check in most cases and
I would prefer not to take this route.

We should have a seperate api that indicates to the plugin that the resources need to be copied from the server
instead of creating fresh copies. 
Comment 17 martin_adamek 2007-06-26 17:27:10 UTC
OK, reopening as P3 as part of the problem was fixed.
Comment 18 Vince Kraemer 2009-04-07 19:46:33 UTC
not assigned to a person. priority is 'correct'
Comment 19 Petr Jiricka 2009-06-05 19:34:58 UTC
"We should have a seperate api that indicates to the plugin..."

Sounds like this change needs to be done on the j2eeserver side, reassigning. 
Comment 20 Petr Hejl 2010-05-10 13:36:40 UTC
I don't really understand what the api should do. Perhaps the description of requested functionality is too short.
Comment 21 Vince Kraemer 2010-05-12 19:45:55 UTC
The dialog implies that the data associated with an existing datasource is going to get copied into the project.  If the user wants to have that happen, the control that they use actually ends up calling a plugin's implementation of DatasourceConfiguration.createDatasource... in part because there is no DatasourceConfiguration.copyDatasource API.

it looks like we need to add the following apis...

org.netbeans.modules.j2ee.deployment.config.ConfigSupportImpl.copyDatasource and org.netbeans.modules.j2ee.deployment.plugins.spi.config.DatasourceConfiguration.copyDatasource

The first one allows the UseDatabaseGenerator to be corrected.  The second will be the spi that a plugin would implement to do a copy instead of a create.

Maybe this stacktrace from the code which currently does the wrong thing will clarify what the new apis and spis should be...

java.lang.Exception: Stack trace
	at java.lang.Thread.dumpStack(
	at org.netbeans.modules.glassfish.javaee.db.Hk2DatasourceManager.createDataSource(
	at org.netbeans.modules.glassfish.javaee.Hk2Configuration.createDatasource(
	at org.netbeans.modules.glassfish.javaee.ModuleConfigurationImpl.createDatasource(
	at org.netbeans.modules.j2ee.deployment.config.ConfigSupportImpl.createDatasource(
	at org.netbeans.modules.j2ee.ejbcore.action.UseDatabaseGenerator.generate(
	at org.netbeans.modules.j2ee.ejbcore.ui.logicalview.entries.UseDatabaseCodeGenerator.invoke(
	at org.netbeans.modules.editor.codegen.GenerateCodePanel.invokeSelected(
	at org.netbeans.modules.editor.codegen.GenerateCodePanel.listMouseReleased(
	at org.netbeans.modules.editor.codegen.GenerateCodePanel.access$200(
	at org.netbeans.modules.editor.codegen.GenerateCodePanel$3.mouseReleased(
	at java.awt.AWTEventMulticaster.mouseReleased(
	at java.awt.Component.processMouseEvent(
	at javax.swing.JComponent.processMouseEvent(
	at java.awt.Component.processEvent(
	at java.awt.Container.processEvent(
	at java.awt.Component.dispatchEventImpl(
	at java.awt.Container.dispatchEventImpl(
	at java.awt.Component.dispatchEvent(
	at java.awt.LightweightDispatcher.retargetMouseEvent(
	at java.awt.LightweightDispatcher.processMouseEvent(
	at java.awt.LightweightDispatcher.dispatchEvent(
	at java.awt.Container.dispatchEventImpl(
	at java.awt.Window.dispatchEventImpl(
	at java.awt.Component.dispatchEvent(
	at java.awt.EventQueue.dispatchEvent(
	at org.netbeans.core.TimableEventQueue.dispatchEvent(
	at java.awt.EventDispatchThread.pumpOneEventForFilters(
	at java.awt.EventDispatchThread.pumpEventsForFilter(
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(
	at java.awt.EventDispatchThread.pumpEvents(
	at java.awt.EventDispatchThread.pumpEvents(