Bug #72850 Connection error while test configuration
Submitted: 3 Jun 2014 13:54 Modified: 11 Jul 2016 5:50
Reporter: Waqas Malik Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.30 OS:Windows (Windows 7)
Assigned to: CPU Architecture:Any
Tags: fabric, weblogic

[3 Jun 2014 13:54] Waqas Malik
Description:
MySQL fabric has two features:
 1. Replication
 2. Routes Transaction

I have implemented the Replication part.

Now I want to add fabric node as a datasource in my application server i.e weblogic. Because i want that my application server should always read/write from the primary node of my fabric setup. I updated my weblogic server with 5.1.30 connector/j to support fabric. 

But during the test connection configuration I am getting the error:

Connection test failed.
Message icon - Error Unable to establish connection to the Fabric server<br/>com.mysql.fabric.jdbc.FabricMySQLDriver.connect(FabricMySQLDriver.java:80)<br/>weblogic.jdbc.common.internal.DataSourceUtil.testConnection0(DataSourceUtil.java:340)<br/>weblogic.jdbc.common.internal.DataSourceUtil.access$000(DataSourceUtil.java:22)<br/>weblogic.jdbc.common.internal.DataSourceUtil$1.run(DataSourceUtil.java:254)<br/>java.security.AccessController.doPrivileged(Native Method)<br/>weblogic.jdbc.common.internal.DataSourceUtil.testConnection(DataSourceUtil.java:251)<br/>com.bea.console.utils.jdbc.JDBCUtils.testConnection(JDBCUtils.java:751)

Regards

How to repeat:
Try to add the datasource in weblogic server. During the test connection configuration this error would comes.
[10 Jun 2014 0:07] Jess Balint
Hi, it appears that the root cause exception is not provided. Can you please check your application server logs for the original exception and stack trace?
[10 Jun 2014 0:09] Jess Balint
Can you please provide your complete connection string?
[11 Jun 2014 13:52] Waqas Malik
Application server

Attachment: mysql-bug-application-server-exception-stack-trace.txt (text/plain), 10.15 KiB.

[11 Jun 2014 13:58] Waqas Malik
Connection Information

Attachment: Connection.jpg (image/jpeg, text), 127.71 KiB.

[11 Jun 2014 14:15] Waqas Malik
I think I am missing datasource correct configuration in weblogic of Fabric node.

Kindly, send me the configurations may be it resolves the issue.

Regards
M.Waqas
[12 Jun 2014 22:13] Jess Balint
It looks like your connection URL is using port 3306 which is the MySQL server port. If your Fabric node is on the same host, please change it to the port of your Fabric server which is 32274 by default.
[13 Jun 2014 6:38] Waqas Malik
Application server stack trace with changing port to default 32274

Attachment: mysql-bug-application-server-exception-stack-trace II.txt (text/plain), 10.17 KiB.

[18 Jun 2014 21:40] Jess Balint
Is the Fabric node running on a different host than you are trying to connect from?

Can you confirm the port from your configuration file? In /etc/mysql/fabric.cfg, you should see something like:

 [protocol.xmlrpc]
 address = localhost:32274
[19 Jun 2014 4:58] Waqas Malik
Yes, Fabric node is running on different host and my application server is on different host.

Secondly, in my fabric.cfg file address parameter is same:

address = localhost:32274
[19 Jun 2014 7:48] Jess Balint
The address value specifies that the Fabric node will only be listening for connections from localhost. To also accept connections from other hosts, please change it to:

 address = :32274
[20 Jun 2014 5:48] Waqas Malik
Even by changing the address = :32274, application server is unable to make connection with fabric server. log is attached.
[20 Jun 2014 5:48] Waqas Malik
Application server log after changing address.

Attachment: application server log.txt (text/plain), 10.17 KiB.

[27 Jun 2014 23:58] Nabeel Alhaddad
Same problem here

Any solution?
[28 Jun 2014 0:16] Jess Balint
Nabeel,

* Is your Fabric server on a different host than the one you're connection from?

* Have you changed the configuration file to allow connections from ALL hosts? (If you telnet to port 32274 on the Fabric host, does it connect?)

* Have you restarted the Fabric node after changing the configuration file?

* Can you please share the complete error message you are seeing?

Thanks!
[28 Jun 2014 0:41] Nabeel Alhaddad
* Is your Fabric server on a different host than the one you're connection from?
Yes

* Have you changed the configuration file to allow connections from ALL hosts? (If you telnet to port 32274 on the Fabric host, does it connect?)
Yes
Now it is like this:
address = :32274

* Have you restarted the Fabric node after changing the configuration file?
Yes

* Can you please share the complete error message you are seeing?

Jun 28, 2014 3:35:48 AM fabricclient.FabricClient main
SEVERE: null
java.sql.SQLException: Unable to establish connection to the Fabric server
	at com.mysql.fabric.jdbc.FabricMySQLDriver.connect(FabricMySQLDriver.java:80)
	at java.sql.DriverManager.getConnection(DriverManager.java:571)
	at java.sql.DriverManager.getConnection(DriverManager.java:215)
	at fabricclient.FabricClient.main(FabricClient.java:28)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Unable to establish connection to the Fabric server
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:408)
	at com.mysql.jdbc.Util.getInstance(Util.java:383)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1023)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:997)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:983)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:928)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:959)
	at com.mysql.fabric.jdbc.FabricMySQLConnectionProxy.<init>(FabricMySQLConnectionProxy.java:187)
	at com.mysql.fabric.jdbc.JDBC4FabricMySQLConnectionProxy.<init>(JDBC4FabricMySQLConnectionProxy.java:92)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:408)
	at com.mysql.fabric.jdbc.FabricMySQLDriver.connect(FabricMySQLDriver.java:77)
	... 3 more
Caused by: com.mysql.fabric.FabricCommunicationException: Error during call to `dump.servers' (args=[Ljava.lang.Object;@3a9ae1ab)
	at com.mysql.fabric.proto.xmlrpc.InternalXmlRpcMethodCaller.call(InternalXmlRpcMethodCaller.java:115)
	at com.mysql.fabric.proto.xmlrpc.XmlRpcClient.callDumpMethod(XmlRpcClient.java:126)
	at com.mysql.fabric.proto.xmlrpc.XmlRpcClient.getServerGroups(XmlRpcClient.java:165)
	at com.mysql.fabric.proto.xmlrpc.XmlRpcClient.getServerGroups(XmlRpcClient.java:185)
	at com.mysql.fabric.FabricConnection.refreshState(FabricConnection.java:70)
	at com.mysql.fabric.FabricConnection.<init>(FabricConnection.java:43)
	at com.mysql.fabric.jdbc.FabricMySQLConnectionProxy.<init>(FabricMySQLConnectionProxy.java:185)
	... 10 more
Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: http://192.168.1.12:32274
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1626)
	at com.mysql.fabric.xmlrpc.Client.execute(Client.java:91)
	at com.mysql.fabric.proto.xmlrpc.InternalXmlRpcMethodCaller.call(InternalXmlRpcMethodCaller.java:112)
	... 16 more
[28 Jun 2014 0:47] Jess Balint
Nabeel,
Thank you. Have you configured a username and password in your Fabric configuration under [protocol.xmlrpc]? You will need to specify them on the JDBC URL with "fabricUsername" and "fabricPassword". These credentials are used to connect to the Fabric node itself - not the individual database servers.

http://dev.mysql.com/doc/mysql-utilities/1.4/en/connector-j-fabric-reference-connection-pr...

Thanks!
[28 Jun 2014 1:04] Nabeel Alhaddad
This is my Java code

            Class.forName("com.mysql.fabric.jdbc.FabricMySQLDriver");
            Connection conn = (Connection) DriverManager.getConnection(
                    "jdbc:mysql:fabric://192.168.1.12:32274/mysql",
                    "admin",
                    "mYpAssWorD");
[28 Jun 2014 1:12] Jess Balint
Do you have a username and password setup in your Fabric configuration, like so:

[protocol.xmlrpc]
address = :32274
threads = 5
user = admin
password = admin

Your URL would be something like:
"jdbc:mysql:fabric://192.168.1.12:32274/mysql?fabricUsername=admin&fabricPassword=admin"
[28 Jun 2014 1:18] Nabeel Alhaddad
Yes I have

No my Java code is like this: 

            Class.forName("com.mysql.fabric.jdbc.FabricMySQLDriver");
            Connection conn = (Connection) DriverManager.getConnection(
                    "jdbc:mysql:fabric://192.168.1.12:32274/mysqlfabricUsername=admin&fabricPassword=G548dsjuE");

No luck :(
[28 Jun 2014 1:21] Jess Balint
Do you have a question mark in there?

mysqlfabricUsername=admin

should be:

mysql?fabricUsername=admin

Please post an updated error message if this isn't working.
[28 Jun 2014 1:23] Jess Balint
Also, you should keep the username and password parameters to the getConnection() method as they are used to connect to the individual MySQL servers.
[28 Jun 2014 1:32] Nabeel Alhaddad
Class.forName("com.mysql.fabric.jdbc.FabricMySQLDriver");
            Connection conn = (Connection) DriverManager.getConnection(
                    "jdbc:mysql:fabric://192.168.1.12:32274/mysql?fabricUsername=admin&fabricPassword=password",
                    "admin",
                    "password");

Error stack:

Jun 28, 2014 4:30:59 AM fabricclient.FabricClient main
SEVERE: null
java.sql.SQLException: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
	at com.mysql.fabric.jdbc.FabricMySQLDriver.connect(FabricMySQLDriver.java:80)
	at java.sql.DriverManager.getConnection(DriverManager.java:571)
	at java.sql.DriverManager.getConnection(DriverManager.java:215)
	at fabricclient.FabricClient.main(FabricClient.java:28)
Caused by: java.sql.SQLException: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1094)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:997)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:983)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:928)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:959)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:949)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:432)
	at com.mysql.fabric.jdbc.FabricMySQLDriver.connect(FabricMySQLDriver.java:77)
	... 3 more
Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
	at com.mysql.fabric.proto.xmlrpc.XmlRpcClient.unmarshallServer(XmlRpcClient.java:83)
	at com.mysql.fabric.proto.xmlrpc.XmlRpcClient.getServerGroups(XmlRpcClient.java:169)
	at com.mysql.fabric.proto.xmlrpc.XmlRpcClient.getServerGroups(XmlRpcClient.java:185)
	at com.mysql.fabric.FabricConnection.refreshState(FabricConnection.java:70)
	at com.mysql.fabric.FabricConnection.<init>(FabricConnection.java:43)
	at com.mysql.fabric.jdbc.FabricMySQLConnectionProxy.<init>(FabricMySQLConnectionProxy.java:185)
	at com.mysql.fabric.jdbc.JDBC4FabricMySQLConnectionProxy.<init>(JDBC4FabricMySQLConnectionProxy.java:92)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:408)
	... 4 more
[28 Jun 2014 1:38] Nabeel Alhaddad
Sorry. ignore the last comment

This is what I have

Java code:

            Class.forName("com.mysql.fabric.jdbc.FabricMySQLDriver");
            Connection conn = (Connection) DriverManager.getConnection(
                    "jdbc:mysql:fabric://192.168.1.12:32274/mysql?fabricUsername=fabric_user&fabricPassword=fabric_password",
                    "database_user",
                    "database_password");

Error stack:

SEVERE: null
java.sql.SQLException: Unable to establish connection to the Fabric server
	at com.mysql.fabric.jdbc.FabricMySQLDriver.connect(FabricMySQLDriver.java:80)
	at java.sql.DriverManager.getConnection(DriverManager.java:571)
	at java.sql.DriverManager.getConnection(DriverManager.java:215)
	at fabricclient.FabricClient.main(FabricClient.java:28)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Unable to establish connection to the Fabric server
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:408)
	at com.mysql.jdbc.Util.getInstance(Util.java:383)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1023)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:997)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:983)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:928)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:959)
	at com.mysql.fabric.jdbc.FabricMySQLConnectionProxy.<init>(FabricMySQLConnectionProxy.java:187)
	at com.mysql.fabric.jdbc.JDBC4FabricMySQLConnectionProxy.<init>(JDBC4FabricMySQLConnectionProxy.java:92)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:408)
	at com.mysql.fabric.jdbc.FabricMySQLDriver.connect(FabricMySQLDriver.java:77)
	... 3 more
Caused by: com.mysql.fabric.FabricCommunicationException: Error during call to `dump.servers' (args=[Ljava.lang.Object;@4b2c7378)
	at com.mysql.fabric.proto.xmlrpc.InternalXmlRpcMethodCaller.call(InternalXmlRpcMethodCaller.java:115)
	at com.mysql.fabric.proto.xmlrpc.AuthenticatedXmlRpcMethodCaller.call(AuthenticatedXmlRpcMethodCaller.java:75)
	at com.mysql.fabric.proto.xmlrpc.XmlRpcClient.callDumpMethod(XmlRpcClient.java:126)
	at com.mysql.fabric.proto.xmlrpc.XmlRpcClient.getServerGroups(XmlRpcClient.java:165)
	at com.mysql.fabric.proto.xmlrpc.XmlRpcClient.getServerGroups(XmlRpcClient.java:185)
	at com.mysql.fabric.FabricConnection.refreshState(FabricConnection.java:70)
	at com.mysql.fabric.FabricConnection.<init>(FabricConnection.java:43)
	at com.mysql.fabric.jdbc.FabricMySQLConnectionProxy.<init>(FabricMySQLConnectionProxy.java:185)
	... 10 more
Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: http://192.168.1.12:32274
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1626)
	at com.mysql.fabric.xmlrpc.Client.execute(Client.java:91)
	at com.mysql.fabric.proto.xmlrpc.InternalXmlRpcMethodCaller.call(InternalXmlRpcMethodCaller.java:112)
	... 17 more
[28 Jun 2014 1:46] Jess Balint
Nabeel,
The last one, that you said to ignore, looks like it's connecting properly to the Fabric server and hitting another more subtle issue. Are you able to reproduce the ClassCastException? Let me check my notes and see what's causing it.
Thanks.
[28 Jun 2014 1:51] Nabeel Alhaddad
Yes, yes. The one I asked you to ignore is what I am having when I put the correct passwords. 

If you could help me resolving the issue with the java.lang.ClassCastException that would be really great.

I am looking forward to hearing from you ..

Regards,
[28 Jun 2014 1:55] Jess Balint
Can you show me the "mysqlfabric group add" commands that you ran to setup your HA groups?
[28 Jun 2014 1:57] Nabeel Alhaddad
it was "mysqlfabric group add group2 192.168.1.13"
[28 Jun 2014 2:01] Jess Balint
Can you remove and re-add the servers and specify the port explicitly:

$ mysqlfabric group add group2 192.168.1.13:3306

Thanks for identifying this. I will make sure it gets fixed.
[28 Jun 2014 2:39] Nabeel Alhaddad
Thank you so much

Now it is working :)

I spent days searching and trying to resolve the issue.

Thanx again
[14 Aug 2014 18:29] Jess Balint
Waqas,
Can you please try this with the latest Connector/J 5.1.32 release? If the problem persists, please include the full output from the Weblogic Server logs.
Thanks.
[15 Sep 2014 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[3 Mar 2016 8:53] mohan sundaram
I am trying to connect MySQL fabric server using below java program.But it is not connecting and throw below exception. Please help me

MySQL connector jar version : mysql-connector-java-5.1.38.jar

public class FabricExample {
	
	public static void main(String args[]){  
		try{  

		      String url = "jdbc:mysql:fabric://fabrichost:63301/mysql?useSSL=false&user=admin&password=secret" +
				"&fabricUsername=fabric&fabricPassword=fabric&fabricServerGroup=fagroup";
		      
		Connection conn = DriverManager.getConnection(url);

		Statement stmt=conn.createStatement();  
		  
		ResultSet rs=stmt.executeQuery("select * from crm_addr_typ_lu");  
		  
		while(rs.next())  
		System.out.println(rs.getInt(1)+"  "+rs.getString(2));  
		  
		conn.close();  
		  
		}catch(Exception e)
		{
			e.printStackTrace();
			
		}  
		  
	}  

}

Exception:

java.sql.SQLException: Unable to establish connection to the Fabric server
	at com.mysql.fabric.jdbc.FabricMySQLDriver.connect(FabricMySQLDriver.java:80)
	at java.sql.DriverManager.getConnection(DriverManager.java:571)
	at java.sql.DriverManager.getConnection(DriverManager.java:233)
	at com.ReplicationExample.main(ReplicationExample.java:28)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Unable to establish connection to the Fabric server
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
	at com.mysql.jdbc.Util.getInstance(Util.java:387)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:917)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:896)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:885)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:877)
	at com.mysql.fabric.jdbc.FabricMySQLConnectionProxy.<init>(FabricMySQLConnectionProxy.java:189)
	at com.mysql.fabric.jdbc.JDBC4FabricMySQLConnectionProxy.<init>(JDBC4FabricMySQLConnectionProxy.java:91)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
	at com.mysql.fabric.jdbc.FabricMySQLDriver.connect(FabricMySQLDriver.java:78)
	... 3 more
Caused by: com.mysql.fabric.FabricCommunicationException: Unable to obtain challenge header for authentication
	at com.mysql.fabric.proto.xmlrpc.AuthenticatedXmlRpcMethodCaller.call(AuthenticatedXmlRpcMethodCaller.java:63)
	at com.mysql.fabric.proto.xmlrpc.XmlRpcClient.errorSafeCallMethod(XmlRpcClient.java:149)
	at com.mysql.fabric.proto.xmlrpc.XmlRpcClient.getServerGroups(XmlRpcClient.java:198)
	at com.mysql.fabric.proto.xmlrpc.XmlRpcClient.getServerGroups(XmlRpcClient.java:218)
	at com.mysql.fabric.FabricConnection.refreshState(FabricConnection.java:68)
	at com.mysql.fabric.FabricConnection.<init>(FabricConnection.java:43)
	at com.mysql.fabric.jdbc.FabricMySQLConnectionProxy.<init>(FabricMySQLConnectionProxy.java:187)
	... 10 more
Caused by: java.io.IOException: Invalid Http response
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1342)
	at com.mysql.fabric.proto.xmlrpc.DigestAuthentication.getChallengeHeader(DigestAuthentication.java:50)
	at com.mysql.fabric.proto.xmlrpc.AuthenticatedXmlRpcMethodCaller.call(AuthenticatedXmlRpcMethodCaller.java:61)
	... 16 more
[11 Jul 2016 5:50] Chiranjeevi Battula
Hello mohan sundaram,

Thank you for your feedback.
This is most likely duplicate of Bug #73901, please see Bug #73901.

Thanks,
Chiranjeevi.