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 235027 - jdbc/__default is not returned for gf4
Summary: jdbc/__default is not returned for gf4
Status: RESOLVED FIXED
Alias: None
Product: serverplugins
Classification: Unclassified
Component: GlassFish (show other bugs)
Version: 7.4
Hardware: PC Windows 7
: P2 normal (vote)
Assignee: TomasKraus
URL:
Keywords:
Depends on:
Blocks: 234729
  Show dependency tree
 
Reported: 2013-08-26 12:06 UTC by Sergey Petrov
Modified: 2013-08-29 10:59 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergey Petrov 2013-08-26 12:06:12 UTC
It's part of https://netbeans.org/bugzilla/show_bug.cgi?id=234729 P2, so P2.

In my opinion comp/DefaultDataSource should be returned by gf plugin as supported server datasource. Also it may need to return both comp/DefaultDataSource and jdbc/__default, currently last one is not returned for gf4 but works fine for gf3.

see Hk2DatasourceManager::getDatasources
Comment 1 TomasKraus 2013-08-26 13:27:21 UTC
Do you have some test case for this?
Comment 2 Sergey Petrov 2013-08-26 13:38:49 UTC
1. new project - web project on gf4
2. new file - Persistence|Persistence Unit
{2} wizard  should contain a list with all existent datasources
Comment 3 Sergey Petrov 2013-08-26 13:43:36 UTC
also
asadmin list-jdbc-resources return jdbc/__default for mine gf4 installation.

I'm not sure yet how java:comp/DefaultDataSource is handled and if it's possible to find somehow or should be added just because it's ee7.
Comment 4 TomasKraus 2013-08-26 14:08:53 UTC
I don't have jdbc/__default deployed on my GF4 so it's not seen in wizard list.
Enter admin password for user "admin"> 
jdbc/sample
jdbc/myPoolDataSource
Command list-jdbc-resources executed successfully.

And this is exactly what I see in wizard.

In GFv3 I do have jdbc/__default deployed on server. Are you really sure that jdbc/__default is deployed on that GF4?

this is what I see in GF3:
==========================
DerbyPool:
----------
DatabaseName	sun-appserv-samples
PortNumber	1527
serverName	localhost
Password	APP
User	APP
connectionAttributes	;create=true

jdbc/__default:
---------------
Pool name: DerbyPool
Enabled: true

I made this resource manually in sample web app in glassfish-resources.xml:
---------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>

  <jdbc-resource enabled="true" jndi-name="jdbc/__default" object-type="user" pool-name="DerbyPool">
    <description/>
  </jdbc-resource>
  <jdbc-connection-pool allow-non-component-callers="false"
                        associate-with-thread="false"
                        connection-creation-retry-attempts="0"
                        connection-creation-retry-interval-in-seconds="10"
                        connection-leak-reclaim="false"
                        connection-leak-timeout-in-seconds="0"
                        connection-validation-method="auto-commit"
                        datasource-classname="org.apache.derby.jdbc.ClientDataSource"
                        fail-all-connections="false" idle-timeout-in-seconds="300"
                        is-connection-validation-required="false"
                        is-isolation-level-guaranteed="true"
                        lazy-connection-association="false"
                        lazy-connection-enlistment="false"
                        match-connections="false"
                        max-connection-usage-count="0" max-pool-size="32"
                        max-wait-time-in-millis="60000" name="DerbyPool"
                        non-transactional-connections="false"
                        ping="false" pool-resize-quantity="2" pooling="true"
                        res-type="javax.sql.DataSource"
                        statement-cache-size="0" statement-leak-reclaim="false"
                        statement-leak-timeout-in-seconds="0"
                        statement-timeout-in-seconds="-1" steady-pool-size="8"
                        validate-atmost-once-period-in-seconds="0"
                        wrap-jdbc-objects="false">
    <property name="URL" value="jdbc:derby://localhost:1527/sun-appserv-samples"/>
    <property name="serverName" value="localhost"/>
    <property name="PortNumber" value="1527"/>
    <property name="DatabaseName" value="sun-appserv-samples"/>
    <property name="User" value="APP"/>
    <property name="Password" value="APP"/>
  </jdbc-connection-pool>

</resources>

Deployed to GFv4
Now back to your wizard and I see all 3 resources in select box.

nb:/users/tomas/WS/gf4b89/glassfish/bin> ./asadmin list-jdbc-resources
Enter admin password for user "admin"> 
jdbc/sample
jdbc/myPoolDataSource
jdbc/__default
Command list-jdbc-resources executed successfully.

So this seems to be working fine for me.
Comment 5 Sergey Petrov 2013-08-26 15:08:37 UTC
I can see /__default in asadmin output and on services tab for gf4 registration but it isn't listed in persistence unit wizard.
Also it may be secondary issue, I'm more interested in DefaultDataSource, do you have any ideas if it's registered somehow or we need to hardcode it somewhere for ee7 platform?
Comment 6 Sergey Petrov 2013-08-26 15:10:46 UTC
this "__default" should be registered by default as I've never use it before but I may need to reverify. I have my gf4 installation from zip distribution.
Comment 7 TomasKraus 2013-08-26 15:23:49 UTC
It probably is registered as default. But users have tool to delete it and they will do so. I'll reinstall GF4 tomorrow to get initial setup and I'll see.
Comment 8 TomasKraus 2013-08-27 09:40:47 UTC
Yes, I can finally reproduce it with clean GF4 installation.
I went trough Hk2DatasourceManager::getDatasources but it does not return anything. This method is designed to retrieve datasources from resources XML file, not from server.
Comment 9 TomasKraus 2013-08-27 10:01:01 UTC
This seems to be our issue:
---------------------------
org.netbeans.modules.glassfish.javaee.db.Hk2DatasourceManager.readDatasources(Hk2DatasourceManager.java:254)
org.netbeans.modules.glassfish.javaee.db.Hk2DatasourceManager.getDatasources(Hk2DatasourceManager.java:126)
org.netbeans.modules.j2ee.deployment.impl.ServerInstance.getDatasources(ServerInstance.java:733)
org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider.getServerDatasources(J2eeModuleProvider.java:207)
org.netbeans.modules.j2ee.common.DatasourceUIHelper.getDatasources(DatasourceUIHelper.java:627)

It's reading data sources from server. 1st time I was checking wrong code path.
There seems to be 2 issues:

1) data sources are always retrieved from local domain.xml, even when registered server is remote
2) code responsible for parsing domain.xml does not see jdbc/__default
Comment 10 Sergey Petrov 2013-08-27 10:32:01 UTC
any ideas about java:comp/DefaultDataSource?
Comment 11 TomasKraus 2013-08-27 17:46:02 UTC
comp/DefaultDataSource was not registered by default in GF4. It should be deployed first.
Comment 12 Sergey Petrov 2013-08-27 18:08:13 UTC
sorry, forget to add link here,
see https://blogs.oracle.com/arungupta/entry/default_datasource_in_java_ee

it must be provided by default and is likely provided, but it may be handled in non standard way, the question what part of gf may provide this information of gf plugin may assume and existence for any ee7 gf  or it's better to hardcode on persistence side as an option.
Comment 13 TomasKraus 2013-08-28 11:51:08 UTC
Checked into GF Tooling Library:
--------------------------------
changeset:   656:f1009d24fdcf
summary:     Bug# 235027 - Fixed asadmin commands and tests related to JDBC data sources and pools, added some helper methods


Checked into web-main:
----------------------
changeset:   262060:b87f3fe21b22
summary:     #235027 - List od deployed data sources is read from server asadmin interface when server is alive

Now when server is running it returns the same data as seen in Services server node.

Finally only one remote asadmin command (the most time consuming operation) is used. It was possible to retrieve everything using 'asadmin get resources.*'. Command will return all resources propeties (not just for JDBC) but data optimized code would require more asadmin commands to be executed.

Whole asadmin get response processing is optimized to avoid multiple list and strings scans. Attribute names detection is based on prefix trees.

This code is currently part of glassfish.javaee module but we may move it into GF Tooling Library later to use it in Eclopse too.

Will push later after fallback domain.xml parser is fixed too.
Comment 14 TomasKraus 2013-08-28 13:34:02 UTC
Checked into web-main:
----------------------
changeset:   262061:1bb7101a1815
summary:     #235027 - Modified domain.xml parser to return all resources including system ones and those with missing URL

changeset:   262062:0cedb15c1709
summary:     #235027 - Cosmetic changes and warnings fixes


Now I'm getting the same results with both methods.

There is just one problem that you may face after this fix is pushed - you will get an empty set when registered glassfish is remote and it's not responding. But providing data from local copy of domain xml is not good, it may differ from target server.

TODO: Update versions and dependencies, run commit validation, push
Comment 15 Sergey Petrov 2013-08-28 13:46:40 UTC
will comp/DefaultDataSource be visible too?

it may be necessary to test cases with "empty" set, what will be returned for stopped local server?
Comment 16 TomasKraus 2013-08-28 14:13:22 UTC
comp/DefaultDataSource is not present in server so it can't be visible.

This must be handled in another way - deploy it when missing. But it's not topic of this issue this is related to bug in listing already deployed resources.

Maybe open another bug to get is addressed and documented in a separate thread.
Comment 17 TomasKraus 2013-08-28 14:43:49 UTC
Fix was pushed into web-main. Please let me know if it's ok now.
comp/DefaultDataSource will be another story. But I'll be working on it ASAP.
Comment 18 Sergey Petrov 2013-08-28 19:36:49 UTC
yes, I can start separate issue for default ee7 datasource.

any ee application without datasource specification/configuration should be able to access this datasource on defaault ee7 server installation.

In real it was primary issue I want to adrees/resolve but occationally the issue with other datasources mix all plans.
Comment 19 Quality Engineering 2013-08-29 01:42:52 UTC
Integrated into 'main-silver', will be available in build *201308290001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/b87f3fe21b22
User: Tomas Kraus <TomasKraus@netbeans.org>
Log: #235027 - List od deployed data sources is read from server asadmin interface when server is alive
Comment 20 Sergey Petrov 2013-08-29 03:52:05 UTC
David, Petr, Tomas,

I need to collect some opinion on design,
if it's not possible to get from configuration but gf/ee7 must support default ee7 datasource, what is the best place to hardcode it on our side - server plugin, ee platform (somewhere in ee.common or similar), or somewhere where is it used (i.e. directly in persistence etc.)
Comment 21 Sergey Petrov 2013-08-29 06:54:45 UTC
finally separate into new issue, see 235203
this one may be cloase as fixed in this case.
Comment 22 Petr Jiricka 2013-08-29 08:44:18 UTC
I agree, Tomas you can close this, and let's continue discussing in bug 235203.
Comment 23 TomasKraus 2013-08-29 10:59:25 UTC
OK, closing.