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.
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]
what server are you deploying to?
glassfish v1 u1 p1 b02
this is actually a plugin code issue
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.
Created attachment 44209 [details] working webapp
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".
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.
On solaris-sparc IDE the web project is marked with a red "!", but not on the windows IDE (nb 6.0 0619)
Stephan, Could you redirect this to the correct component/contact who deals with Resource Injections.
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
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....
Fixed. Reference name set by user in dialog is used in code (even in annotation). We might discuss if it is good for injection case, but currently this behavior follows UI better, than using plain JNDI name. Please verify, so I can commit to M10 branch. http://www.netbeans.org/source/browse/j2ee/ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entres/SelectDatabasePanel.form?r1=1.6&r2=1.7 http://www.netbeans.org/source/browse/j2ee/ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entres/SelectDatabasePanel.java?r1=1.11&r2=1.12 http://www.netbeans.org/source/browse/j2ee/ejbcore/src/org/netbeans/modules/j2ee/ejbcore/action/UseDatabaseGenerator.java?r1=1.7&r2=1.8 http://www.netbeans.org/source/browse/j2ee/ejbcore/test/unit/src/org/netbeans/modules/j2ee/ejbcore/action/UseDatabaseGeneratorTest.java?r1=1.6&r2=1.7
Sorry, forgot to reassign to me, so just adding to CC now.
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.
I implemented and tested resource creation when checkbox is selected. Did you try it?
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.
OK, reopening as P3 as part of the problem was fixed.
not assigned to a person. priority is 'correct'
"We should have a seperate api that indicates to the plugin..." Sounds like this change needs to be done on the j2eeserver side, reassigning.
I don't really understand what the api should do. Perhaps the description of requested functionality is too short.
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