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 235203

Summary: Need support for default ee7 datasource from gf plugin (java:comp/DefaultDataSource)
Product: serverplugins Reporter: Sergey Petrov <sj-nb>
Component: GlassFishAssignee: Petr Hejl <phejl>
Status: RESOLVED FIXED    
Severity: normal CC: dkonecny, phejl, pjiricka
Priority: P3    
Version: 7.4   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Bug Depends on:    
Bug Blocks: 235026    

Description Sergey Petrov 2013-08-29 06:51:10 UTC
see issue 235027, issue 234729.

it's required to have suport from gf as usual datasources provide connection information, I need also connection information for this ee7 default datasource.

regarding if it need to be returned by gf plugin in usual list I have no certain opinion yet, it may be separate method like "getDefaultEE7Datasource" or similar.
Comment 1 Sergey Petrov 2013-08-29 06:54:27 UTC
Petr, is default datasource support P2 issue yet after resoleve of additional issues?
Comment 2 Petr Hejl 2013-08-29 07:30:08 UTC
In case any hardcoding would happen I think the right place is GF plugin. As other EE servers may differ in particular IDE-required things. We may generalize any time later.
Comment 3 Sergey Petrov 2013-08-29 08:24:20 UTC
It's not clear yet in https://blogs.oracle.com/arungupta/entry/default_datasource_in_java_ee why it was decided default ee7 is binded to jdbc/__default, even if it is. Also it's a question if binding can be changed or not for gf4. It may affect if we can hardcode on nb side or not. Also it's not clear how gf4 will work with removed jdbc/__default, is there any fake "null" datasource to bind in this case. I may need to try some usecases if nobody know.
Comment 4 Petr Jiricka 2013-08-29 08:54:22 UTC
> Petr, is default datasource support P2 issue yet after resoleve 
> of additional issues?

I think not, now it's P3 - of course it would still be good to address for 7.4. But now I think it's more important to fix issue 235026 than issue 234729.
Comment 5 Petr Jiricka 2013-08-29 09:02:52 UTC
> In case any hardcoding would happen I think the right place is GF plugin.

But then, the "getDefaultEE7Datasource" (or similar) method would also need to be added to server integration API, no? Isn't that too complicated especially if we are considering to fix this for 7.4? I would say that since GF 4 is the only EE 7 compliant server right now, as a hotfix for 7.4 it is ok to also hardcode on the Persistence side, if it will make things easier.

Then we should think about the correct way to fix this, and file an extra issue for fixing properly in 8.0 (which is when we may support additional EE 7 servers like Tomcat 8 or TomEE version built on top of Tomcat 8).
Comment 6 Petr Hejl 2013-08-29 09:07:43 UTC
(In reply to Petr Jiricka from comment #5)
> > In case any hardcoding would happen I think the right place is GF plugin.
> 
> But then, the "getDefaultEE7Datasource" (or similar) method would also need
> to be added to server integration API, no?
In case of a special method, yes. I supposed this can be returned as a standard DS from DataSourceManager.getDataSources() unless there is special handling needed.
Comment 7 TomasKraus 2013-08-29 09:50:14 UTC
Well, I can return one more data source named comp/DefaultDataSource and connect it with existing DerbyPool connection pool used for jdbc/__default.

This should be easily done with new asadmin code I finished yesterday - I have data source and pools in separate objects linked together and data soiurce entity covers Datasource interface.

Unfortunately old domain.xml reader code has everything mixed together. But I'll make some temporary hack there. I'll rewrite it in better way after code freeze.
Comment 8 Sergey Petrov 2013-08-29 09:58:31 UTC
it may be a good option, I still may need to hardcode something to consider this one as default in case if no datasources is specified in persistence.xml but it seems reasonale solution.
Comment 9 TomasKraus 2013-08-29 12:13:26 UTC
Checled into web-main:
----------------------
changeset:   262562:bf12a17a8265
summary:     #235203 - Default Java EE 7 resource (comp/DefaultDataSource) clonned from jdbc/__default. Easy hack for 7.4.

This should resolve problem for 7.4. But I don't think it's a final solution. Check http://download.oracle.com/otndocs/jcp/java_ee-7-pr-spec/index.html
In chapter EE.5.20 this is described as common Java EE 7 behaviour and nothing says that it shall be deployed as regular DataSource.

It just says that comp/DefaultDataSource shall be mapped to something that exists in the server. In case of Glassfish it's jdbc/__default.
In the future (next release) I would like to remove 262562:bf12a17a8265 changeset. DatasourceManager#getDatasources() methods should provide reality - list of data sources deployed on server. Not fake ones like comp/DefaultDataSource which are just application level aliases.

But if there is a strong argument to include those aliases, DatasourceManager can be extended to return aliases mapping for any Java EE compliant server.

Something like
/**
 * Retrieve data sources aliases mapping for the server.
 *
 * @return Data source aliases JNDI names mapped to physical dData sources JNDI names deployed on server.
 */
public Map<String, String> getDatasourceAliases();

For GF v4 if will return comp/DefaultDataSource -> jdbc/__default.
Comment 10 Quality Engineering 2013-08-30 01:43:48 UTC
Integrated into 'main-silver', will be available in build *201308300001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/bf12a17a8265
User: Tomas Kraus <TomasKraus@netbeans.org>
Log: #235203 - Default Java EE 7 resource (comp/DefaultDataSource) clonned from jdbc/__default. Easy hack for 7.4.
Comment 11 Petr Jiricka 2013-08-30 07:38:45 UTC
So Tomas, are you leaving this open for 8.0 on purpose?
Comment 12 Sergey Petrov 2013-08-30 08:43:23 UTC
ds should be "java:comp/DefaultDataSource" instead of "comp/DefaultDataSource"
Comment 13 TomasKraus 2013-08-30 09:36:27 UTC
We can do it in better way for next release. This is not problem of GlassFish only.
Comment 14 TomasKraus 2013-08-30 09:58:09 UTC
Checled into web-main:
----------------------
changeset:   262649:a06559f9f7d7
summary:     #235203 - Fixed JNDI name of Java EE 7 resource DefaultDataSource
Comment 15 Quality Engineering 2013-08-31 01:27:28 UTC
Integrated into 'main-silver', will be available in build *201308310001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/a06559f9f7d7
User: Tomas Kraus <TomasKraus@netbeans.org>
Log: #235203 - Fixed JNDI name of Java EE 7 resource DefaultDataSource
Comment 16 Sergey Petrov 2013-08-31 15:53:48 UTC
the issue related to  the ds implementation on gf side https://java.net/projects/glassfish/lists/issues/archive/2012-12/message/355

may provide some hint on what is this default ds and may be what we can do on nb side. but I can't find sources.
Comment 17 Petr Hejl 2015-09-10 12:52:23 UTC
I don't think there is anything to add unless there is a case where the IDE needs to distinct the default DS from the ordinary one.