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
Need to find out what the proper usage of this annotation is.
Created attachment 44209 [details]
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.
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...
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.
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