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 71093

Summary: Working with the data sources
Product: serverplugins Reporter: Libor Kotouc <lkotouc>
Component: JBossAssignee: Libor Kotouc <lkotouc>
Status: STARTED ---    
Severity: blocker CC: pbuzek
Priority: P1    
Version: 5.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description Libor Kotouc 2006-01-06 14:42:14 UTC
There is a need to define the datasource when a user wants to use some
enterprise resources, e.g. 'Use Database'.

There are basically two parts:
1. create a data source within the project's target server (if it is not there
already)
2. bind the server-specific deployment descriptor with this data source

It will vary for the web and EJB project, AFAIK at least the server-specific
descriptors are different but the mechanism stays same.

The question is which use cases will be involved in addition to 'Use Database'
on the Servlet. One possibility is when a user imports or creates an entity
bean, but I don't know now whether there will be implemented for EJB3.0 only or
whether it will work also for EJB2.1 (if there is a difference at all).

add 1. 
A. We will need to detect the DS existence. The datasource can be defined in a
separate XML file in the deploy subdirectory (JBoss uses a convention
<db-type>-ds.xml) but it is probably possible to add the definition into an
existing file, e.g. to some other data source definition. It can be perhaps
placed under another directory then deploy.
So, one way is to use some file searching heuristic to find the data source.
Another way is to use JMX interface, I must to explore it a little bit to find
out some good mechanism - the most reliable way could be finding the database
driver in the DS with the same name as a project generates.

B. Another problem is when the data source should be deployed (by copying in
fact), whether immediatelly after its creation or during a project deploy.
Comment 1 Libor Kotouc 2006-01-06 14:46:29 UTC
*** Issue 71092 has been marked as a duplicate of this issue. ***
Comment 2 Libor Kotouc 2006-01-06 14:58:59 UTC
Using JMx when detecting data source existence implies a server to be in the
running state.
Comment 3 Chris Webster 2006-01-06 17:38:44 UTC
Will the JBoss plug-in support also handle JMS type interactions for MDB or is
this RFE only for DataBase type connections. Also, will the support deploy the
appropriate drivers to the JBoss server ?
Comment 4 Libor Kotouc 2006-01-06 17:51:10 UTC
This RFE is for working with databases. I cannot say now whether we will do
other types.

And yes, the support will deploy the data source definition to the target server.
Comment 5 Libor Kotouc 2006-01-07 12:47:00 UTC
JBoss does not bind the data sources to 'java:comp/env', but only to 'java:'
namespace. Thus we must map the generated datasource (say jdbc/MyDatabase)
through a server-specific deployment descriptor to the real JNDI name like this
(jboss-web.xml):

  <resource-ref>
    <res-ref-name>jdbc/MyDatabase</res-ref-name>
    <jndi-name>java:jdbc/MyDatabase</jndi-name>
  </resource-ref>

This works for the servlets where a web project generates lookup for
'java:/comp/env/jdbc/MyDatabase' and even for the JSP pages where the JSTL
sql:query tag is used (JSTL 1.1 implementation prefixes the given dataSource
attribute with 'java:comp/env').
Comment 6 Libor Kotouc 2006-01-09 10:14:01 UTC
To adding a data source to a target server:

it would be nice to place the appropriate driver into a target server, too. The
JBoss server does not listen on the lib directory changes by default, thus a
server must be restarted before deploying a data source.

Also, we must detect a situation when a user changes a data source in a project
(driver class) and then not to copy the driver class.

etc.
Comment 7 Libor Kotouc 2006-01-09 16:51:48 UTC
Branch for this issue was created:

branch root:
issue71093_branch_root

branch name:
issue71093_branch
Comment 8 Libor Kotouc 2006-01-23 15:10:21 UTC
- tag on the issue71093_branch BEFORE merging it into javaee5 branch:
issue71093_branch_before_merge_to_javaee5

- tag on the javaee5 branch BEFORE merging it with issue71093_branch branch:
javaee5_before_merge_with_issue71093_branch

- tag on the javaee5 branch AFTER merging it with issue71093_branch branch:
javaee5_after_merge_with_issue71093_branch

Changes between issue71093_branch_root and
issue71093_branch_before_merge_to_javaee5 were merged into javaee5 branch =>
result tag name is javaee5_after_merge_with_issue71093_branch.
Comment 9 Jiri Prox 2007-09-17 21:36:09 UTC
Obsolete milestone, please reevaluate