Bug 107653 - Unable to deploy web application after using Use Database action
Unable to deploy web application after using Use Database action
Status: NEW
Product: serverplugins
Classification: Unclassified
Component: Infrastructure
6.x
All All
: P2 (vote)
: 6.x
Assigned To: Petr Hejl
issues@serverplugins
: API
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-06-21 15:14 UTC by Michal Mocnak
Modified: 2010-05-13 09:12 UTC (History)
8 users (show)

See Also:
Issue Type: ENHANCEMENT
:


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

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
http://java.sun.com/javaee/5/docs/api/javax/annotation/Resource.html#name()

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.

nouar.
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...
https://glassfish.dev.java.net/javaee5/ejb/compdependencies_xmlforum_nov15.pdf

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(Thread.java:1230)
	at org.netbeans.modules.glassfish.javaee.db.Hk2DatasourceManager.createDataSource(Hk2DatasourceManager.java:388)
	at org.netbeans.modules.glassfish.javaee.Hk2Configuration.createDatasource(Hk2Configuration.java:105)
	at org.netbeans.modules.glassfish.javaee.ModuleConfigurationImpl.createDatasource(ModuleConfigurationImpl.java:140)
	at org.netbeans.modules.j2ee.deployment.config.ConfigSupportImpl.createDatasource(ConfigSupportImpl.java:376)
	at org.netbeans.modules.j2ee.ejbcore.action.UseDatabaseGenerator.generate(UseDatabaseGenerator.java:116)
	at org.netbeans.modules.j2ee.ejbcore.ui.logicalview.entries.UseDatabaseCodeGenerator.invoke(UseDatabaseCodeGenerator.java:191)
	at org.netbeans.modules.editor.codegen.GenerateCodePanel.invokeSelected(GenerateCodePanel.java:159)
	at org.netbeans.modules.editor.codegen.GenerateCodePanel.listMouseReleased(GenerateCodePanel.java:122)
	at org.netbeans.modules.editor.codegen.GenerateCodePanel.access$200(GenerateCodePanel.java:60)
	at org.netbeans.modules.editor.codegen.GenerateCodePanel$3.mouseReleased(GenerateCodePanel.java:108)
	at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:273)
	at java.awt.Component.processMouseEvent(Component.java:6348)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3255)
	at java.awt.Component.processEvent(Component.java:6113)
	at java.awt.Container.processEvent(Container.java:2085)
	at java.awt.Component.dispatchEventImpl(Component.java:4714)
	at java.awt.Container.dispatchEventImpl(Container.java:2143)
	at java.awt.Component.dispatchEvent(Component.java:4544)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4618)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4282)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4212)
	at java.awt.Container.dispatchEventImpl(Container.java:2129)
	at java.awt.Window.dispatchEventImpl(Window.java:2475)
	at java.awt.Component.dispatchEvent(Component.java:4544)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:635)
	at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:134)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

HTH


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