Bug 1107120

Summary: Failures when deploying MySQL JDBC driver to EAP 6.x
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Josef Cacek <jcacek>
Component: JCAAssignee: tom.jenkinson
Status: CLOSED CURRENTRELEASE QA Contact: Martin Simka <msimka>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.3.0CC: csplrj, dandread, kkhan, ochaloup, thomas.szadel, tom.jenkinson, zroubali
Target Milestone: DR1   
Target Release: EAP 6.4.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
A previous release of JBoss EAP 6 carried a bug that prevented the MySQL JDBC driver being depoyed under certain circumstances. The deployment would fail, informing the user that the deployment already existed. Any attempt to remove an existing deployment also failed. This issue has been resolved and the driver deploys as expected.
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Josef Cacek 2014-06-09 19:41:39 UTC
When 2 or more classes are used in META-INF/services/java.sql.Driver, then adding the JDBC driver fails with message:
JBAS014749: Operation handler failed: Service jboss.jdbc-driver.mysql is already registered

Steps to reproduce - Follow instructions "6.2.2. Install a JDBC Driver as a Core Module" in Admin guide [1]:

1) download MySQL JDBC driver from [2], put it under [EAP_INST]/modules/com/mysql/main/ and create also module.xml

2) run ./standalone.sh

3) run CLI command:
/subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql,driver-module-name=com.mysql,driver-xa-datasource-class-name=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource)

It results in response:
{     
    "outcome" => "failed",
    "failure-description" => "JBAS014749: Operation handler failed: Service jboss.jdbc-driver.mysql is already registered",
    "rolled-back" => true
}

And server-log contains exception [3].

4.a) when the user realizes there are 2 driver classes, he can try to fix the problem with specifying the driver class:
/subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql,driver-module-name=com.mysql,driver-xa-datasource-class-name=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource, driver-class-name=com.mysql.jdbc.Driver)

but:
{
    "outcome" => "failed",
    "failure-description" => "JBAS010434: Unable to instantiate driver class \"com.mysql.jdbc.Driver\". See log (WARN) for more details",
    "rolled-back" => true
}

4.b) so the user tries to delete existing instance:
/subsystem=datasources/jdbc-driver=mysql:remove

but:
{     
    "outcome" => "failed",
    "failure-description" => "JBAS014807: Management resource '[
    (\"subsystem\" => \"datasources\"),
    (\"jdbc-driver\" => \"mysql\")
]' not found",
    "rolled-back" => true
}

5) when user reload (or restart) server, he's able to add the driver:
[standalone@localhost:9999 /] reload
[standalone@localhost:9999 /] /subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql,driver-module-name=com.mysql,driver-xa-datasource-class-name=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource, driver-class-name=com.mysql.jdbc.Driver)
{"outcome" => "success"}


Points 3, 4.a and 4.b shows issues when adding the JDBC driver.

[1] https://access.redhat.com/site/documentation/en-US/JBoss_Enterprise_Application_Platform/6.2/html/Administration_and_Configuration_Guide/Install_a_JDBC_Driver_as_a_Core_Module1.html
[2] http://dev.mysql.com/downloads/connector/j/

[3]
21:24:20,463 INFO  [org.jboss.as.connector.subsystems.datasources] (management-handler-thread - 3) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
21:24:20,475 INFO  [org.jboss.as.connector.subsystems.datasources] (management-handler-thread - 3) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.fabric.jdbc.FabricMySQLDriver (version 5.1)
21:24:20,486 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 3) JBAS014612: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("jdbc-driver" => "mysql")
]): org.jboss.msc.service.DuplicateServiceException: Service jboss.jdbc-driver.mysql is already registered
	at org.jboss.msc.service.ServiceRegistrationImpl.setInstance(ServiceRegistrationImpl.java:158) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
	at org.jboss.msc.service.ServiceControllerImpl.startInstallation(ServiceControllerImpl.java:236) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
	at org.jboss.msc.service.ServiceContainerImpl.install(ServiceContainerImpl.java:742) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
	at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:243) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
	at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2433) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
	at org.jboss.msc.service.ServiceBuilderImpl.install(ServiceBuilderImpl.java:345) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
	at org.jboss.as.controller.OperationContextImpl$ContextServiceBuilder.install(OperationContextImpl.java:1672) [jboss-as-controller-7.4.0.Final-redhat-15.jar:7.4.0.Final-redhat-15]
	at org.jboss.as.connector.subsystems.datasources.JdbcDriverAdd.startDriverServices(JdbcDriverAdd.java:160)
	at org.jboss.as.connector.subsystems.datasources.JdbcDriverAdd.performRuntime(JdbcDriverAdd.java:118)
...

Comment 1 Josef Cacek 2014-06-10 09:53:22 UTC
The problem can be reproduced with MySQL driver version 5.1.30 and newer. Older versions have only 1 entry in the META-INF/services/java.sql.Driver file.

Comment 2 Stefano Maestri 2014-09-10 14:42:11 UTC
Need a backport of jira issue

Comment 3 Kabir Khan 2014-09-15 11:20:58 UTC
https://github.com/jbossas/jboss-eap/pull/1674

Comment 4 Jeff Zhang 2014-09-16 10:18:42 UTC
PR https://github.com/jbossas/jboss-eap/pull/1674 for 6.X had been merged.
PR for 6.3.X is https://github.com/jbossas/jboss-eap/pull/1688

Comment 5 Martin Simka 2014-09-18 12:06:04 UTC
verified on EAP 6.4.0.DR1.1