Bug 1127869

Summary: DataSource and XADataSource standalone and profile components can not be configured when JARs are deployed to EAP server
Product: [JBoss] JBoss Operations Network Reporter: John Mazzitelli <mazz>
Component: Plugin -- JBoss EAP 6, UIAssignee: RHQ Project Maintainer <rhq-maint>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: high Docs Contact:
Priority: unspecified    
Version: JON 3.2.1CC: loleary, mfoley, miburman, myarboro, skondkar
Target Milestone: ER01Keywords: Triaged
Target Release: JON 3.3.0Flags: jmorgan: needinfo? (mfoley)
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
An issue with the Driver_Name property of a managed deployment containing invalid values prevented users from updating the DataSource and XADataSource component configuration. If there were three or less JARs installed, and the current configuration value did not equal the name of one of the JARs, navigating to a DataSource resource's configuration page generated a banner error. If there were four or more JARs installed, the property changed from a radio-button to a drop-down list. In this case, the error was not displayed. If the target driver was installed as a module or had a corresponding driver entry in the JBoss EAP server's configuration, it was not listed in the drop-down. This also prevented configuration from being updated. The fix now only allows selecting a proper JDBC driver in the datasource configuration, which corrects the reported issue.
Story Points: ---
Clone Of: 1120411 Environment:
Last Closed: 2014-12-11 14:03:33 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 1120411, 1123846    
Attachments:
Description Flags
screenshot_JON3.3ER01 none

Description John Mazzitelli 2014-08-07 18:01:33 UTC
+++ This bug was initially created as a clone of Bug #1120411 +++

Description of problem:
When one or more JARs are deployed to an JBoss EAP server as a managed deployment -- such as EJBs, JDBC4 drivers, libraries, and other managed deployments which have a file name that ends with .jar -- DataSource and XADataSource component configuration can not be updated. This is because the _Driver Name_ property contains an invalid value and the available items from the list do not reflect installed or available drivers in the JBoss EAP server.

If there are three or less JARs installed and the current configuration value does not equal the name of one of the JARs, navigating to a DataSource resource's configuration page, the user sees the following error:

    The following configuration properties have invalid values: [Driver Name]. The values must be corrected before the configuration can be saved.

If there are four or more JARs installed, the property changes from a radio-button to a drop-down list. In this case, the error is not displayed but if the target driver is installed as a module or has a corresponding driver entry in the JBoss EAP server's configuration, it is not listed in the drop-down. Meaning that configuration can not be updated or changed. 

This issue also affects new data sources being created.

Version-Release number of selected component (if applicable):
3.2.1

How reproducible:
Always

Steps to Reproduce:
1.  Install and start JBoss EAP 6 standalone server.
2.  Deploy some fake JAR files to JBoss EAP server:

        (
            JBOSS_HOME="${TESTENV_DIR}"'/jboss-eap-6.2.0.GA'
            _tmp="$(mktemp -d)"
            mkdir -p "${_tmp}"/fake-jar-01
            mkdir -p "${_tmp}"/fake-jar-02
            mkdir -p "${_tmp}"/fake-jar-03
            touch "${_tmp}"/fake-jar-01/empty-file
            touch "${_tmp}"/fake-jar-02/empty-file
            touch "${_tmp}"/fake-jar-03/empty-file
            cd "${_tmp}"
            zip -r fake-jar-01.jar fake-jar-01
            zip -r fake-jar-02.jar fake-jar-02
            zip -r fake-jar-03.jar fake-jar-03
            mv *.jar /tmp
            cd /tmp
            rm -rf "${_tmp}"
            "$JBOSS_HOME"/bin/jboss-cli.sh --connect --command="deploy /tmp/fake-jar-01.jar"
            "$JBOSS_HOME"/bin/jboss-cli.sh --connect --command="deploy /tmp/fake-jar-02.jar"
            "$JBOSS_HOME"/bin/jboss-cli.sh --connect --command="deploy /tmp/fake-jar-03.jar"
        )

3.  Install and start JBoss ON system.
4.  Import JBoss EAP standalone server into inventory.
5.  Update connection settings for JBoss EAP resource as needed.
6.  Navigate to the current configuration page of the EAP / datasources / DataSource (Standalone) / ExampleDS resource.
7.  Add another fake JAR file to the JBoss EAP server:

        (
            JBOSS_HOME="${TESTENV_DIR}"'/jboss-eap-6.2.0.GA'
            _tmp="$(mktemp -d)"
            mkdir -p "${_tmp}"/fake-jar-04
            touch "${_tmp}"/fake-jar-04/empty-file
            cd "${_tmp}"
            zip -r fake-jar-04.jar fake-jar-04
            mv *.jar /tmp
            cd /tmp
            rm -rf "${_tmp}"
            "$JBOSS_HOME"/bin/jboss-cli.sh --connect --command="deploy /tmp/fake-jar-04.jar"
        )

8.  Invoke service discovery and wait for it to complete.
9.  Navigate to the current configuration page of the EAP / datasources / DataSource (Standalone) / ExampleDS resource.
10. From _Driver Name_ drop-down, select _fake-jar-01.jar_.
11. Attempt to change _Driver Name_ drop-down back to _h2_ -- its original and correct value.

Actual results:
After step 6., the error banner at the top of the page displays:

    The following configuration properties have invalid values: [Driver Name]. The values must be corrected before the configuration can be saved.
    
You are unable to update any configuration due to the _Driver Name_ field containing an invalid value with no way of fixing it.

After step 9., the control changes from a radio-button to a drop-down and you can now update other configuration properties but as demonstrated in step 11. you can not set _Driver Name_ to a valid driver defined in the JBoss EAP configuration.

Expected results:
_Driver Name_ field after step 6. and step 11. only displays _h2_ as this is the only driver installed in JBoss EAP 6.2.

No error message is displayed at step 6.

Additionally, perhaps a separate test case, if a JDBC 4 driver has been deployed, it too show appear as a valid option.

Additional info:
The UI control switch between step 6. and step 9. seems strange. It would make sense that the current selection -- of _h2_ -- appear as a radio-button after step 6. However, I am sure it would if the available drivers were actually being displayed.

One can see the actual available drivers:

    "$JBOSS_HOME"/bin/jboss-cli.sh --connect --command="/subsystem=datasources:installed-drivers-list"

    {
        "outcome" => "success",
        "result" => [{
            "driver-name" => "h2",
            "deployment-name" => undefined,
            "driver-module-name" => "com.h2database.h2",
            "module-slot" => "main",
            "driver-datasource-class-name" => "",
            "driver-xa-datasource-class-name" => "org.h2.jdbcx.JdbcDataSource",
            "driver-class-name" => "org.h2.Driver",
            "driver-major-version" => 1,
            "driver-minor-version" => 3,
            "jdbc-compliant" => true
        }]
    }

If you deploy a JDBC 4 driver, it too will appear in the above output.

The root cause of this issue is that the _Dirver Name_ property is populated with a list of all JARs deployed in the JBoss EAP server. Not sure why we are doing this as JARs on their own do not equate to datasource driver names. Only JARs that are self-contained JDBC version 4+ drivers can be deployed in this manner. Modules or user defined datasources or XA datasource drivers are configured via modules and server configuration and will never show up in _Deployments_:

        <c:simple-property name="driver-name" required="true" type="string" description="Name of the (existing) JDBC driver to use" readOnly="false">
          <c:option-source target="resource" expression="type=^Deployment$" filter=".*\.jar"/>
        </c:simple-property>

--- Additional comment from Larry O'Leary on 2014-07-16 17:02:59 EDT ---

Screen shot showing error and UI radio-buttons at Step 6. This error prevents the user from updating any of the configuration for ExampleDS datasource.

--- Additional comment from Larry O'Leary on 2014-07-16 18:05:01 EDT ---

Screen shot showing UI drop-down at Step 9. No error here because the drop-down is populated with _ha_ and this is selected by default.

--- Additional comment from Larry O'Leary on 2014-07-16 18:09:25 EDT ---

Screen shot showing UI drop-down at Step 11. Notice that _h2_ is no longer in the drop-down.

--- Additional comment from Michael Burman on 2014-07-28 16:34:25 EDT ---

Fixed in master

commit e99089debfa95ad99d333c38414ff780b3ecf446
Author: Michael Burman <miburman@redhat.com>
Date:   Mon Jul 28 15:02:43 2014 +0300

    [BZ 1120411] Only allow selecting a proper jdbc driver in the datasource configuration

--- Additional comment from Michael Burman on 2014-07-29 16:18:01 EDT ---

AS7-951 caused issues with (Profile), have to edit this.

--- Additional comment from Michael Burman on 2014-07-30 16:27:49 EDT ---

Commits in master solve issues with testing and Profile (need to be applied in this order):

a106392596b6f8e717ee57c7a7b33d8ea891b9e4
c83e8c4536b07b7ea9b6571ef68af11c41018234

Comment 1 Michael Burman 2014-08-11 09:24:13 UTC
commit 218c6bebde400f5d16eca0adf70599c97185bfd2
Author: burmanm <miburman@redhat.com>
Date:   Wed Jul 30 20:10:21 2014 +0300

    [BZ 1120411] Fix the integration tests and move selection from profile to managed
    
    (cherry picked from commit c83e8c4536b07b7ea9b6571ef68af11c41018234)

commit 4c237989185b81d7ffe46110a54cba4a4fa2a0f1
Author: burmanm <miburman@redhat.com>
Date:   Wed Jul 30 16:39:45 2014 +0300

    [BZ 1120411] Datasources (*) should not be tested like a datasource
    
    (cherry picked from commit a106392596b6f8e717ee57c7a7b33d8ea891b9e4)

commit d88b854bc2e0746c7befe4be4792a7afbbeeadf2
Author: Michael Burman <miburman@redhat.com>
Date:   Mon Jul 28 15:02:43 2014 +0300

    [BZ 1120411] Only allow selecting a proper jdbc driver in the datasource configuration
    
    (cherry picked from commit 28df962ff235511387aff36d79133ed503dc7769)

Comment 2 Simeon Pinder 2014-08-19 23:50:25 UTC
Moving to ON_QA as available to test in the following brew build:

https://brewweb.devel.redhat.com//buildinfo?buildID=379025

Comment 3 Michael Burman 2014-08-21 11:51:54 UTC
Just a note, this will not work with AS7.1.1 (community version) as that one has a regression (attribute drivers-list is empty).

Comment 4 Sunil Kondkar 2014-08-21 13:10:13 UTC
Verified on Version : 3.3.0.ER01 Build Number : 23b3476:f3aa7e7

Followed the steps and verified that no error message is displayed at step 6. 'Driver Name' field displays only 'h2' after step 6 and step 11. 

Please refer the attached screenshot.

Comment 5 Sunil Kondkar 2014-08-21 13:11:03 UTC
Created attachment 929204 [details]
screenshot_JON3.3ER01

Comment 6 Michael Burman 2014-08-25 09:09:37 UTC
*** Bug 1123846 has been marked as a duplicate of this bug. ***