Bug #64983 5.1.19 not working with JBoss AS 4.2.3.GA
Submitted: 14 Apr 2012 23:08 Modified: 1 May 2012 3:37
Reporter: Kenneth Christensen Email Updates:
Status: Closed Impact on me:
Category:Connector / J Severity:S2 (Serious)
Version:5.1.19 OS:Any
Assigned to: Alexander Soklakov CPU Architecture:Any
Tags: regression

[14 Apr 2012 23:08] Kenneth Christensen
5.1.19 is not working together with JBoss AS 4.2.3 (no problems with 5.1.18):

5.1.19 error (MySQLNonTransientConnectionException: Bad handshake):

2012-04-15 00:47:21,362 WARN  [org.jboss.resource.connectionmanager.JBossManagedConnectionPool] Throwable while attempting to get a new connection: null
org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Bad handshake)
	at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:190)
	at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:619)
	at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:264)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Bad handshake
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

How to repeat:
Replace 5.1.18 with 5.1.19 and start the JBoss AS 4.2.3.GA server
[16 Apr 2012 13:23] Alexander Soklakov
Hello Kenneth!

Thanks for your report. But I cannot repeat this on my system. Could you provide more details: OS, jvm version, mysql server version, datasource config?
[20 Apr 2012 8:24] Eric Cartman
I have the same problem with the 5.1.19 version of the Java connector together with JBoss 6.1.0 on a 64 bit RHEL. The MySQL server version is 5.5.12 and my datasource configuration file looks as follows:

<?xml version="1.0" encoding="UTF-8"?>




This must be a regression as everything was working fine in version 5.1.18 and also in earlier versions of the connector. I haven't changed the datasource configuration or MySQL server setup at all, just updated the connector to 5.1.19 and it does no longer work.
[20 Apr 2012 8:46] Alexander Soklakov
Hi Eric,

Could you get tcpdump of that bad handshake? I still cannot repeat the problem.
[20 Apr 2012 9:25] Eric Cartman
Unfortunately i cannot get such a dump, i do not even have root access on that machine. If i can help by providing some other information, please let me know.
[20 Apr 2012 10:01] Alexander Soklakov

One question: do you use "old-passwords" option, i.e. old-style password encryption?

I've got "Bad handshake" with that one. It looks like bug in MysqlOldPasswordPlugin implementation.
[20 Apr 2012 20:31] Kenneth Christensen
I'm not using the "old passwords" option:

| old_passwords                                     | OFF

The MySQL version is 5.5.21 and I have only tested it on my development machine which is a Mac OS X 10.7.3 and JDK 1.6.0_31.

Here is my datasource:




        <!-- The number of prepared statements per connection to be kept open and reused in subsequent requests. They are stored in a LRU cache. The default is 0 (zero), meaning no cache. -->
        <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->

        <!-- Checks the MySQL error codes and messages for fatal errors -->

Above works fine with 5.1.18 but not with 5.1.19.
[23 Apr 2012 8:37] Alexander Soklakov

What is the length of password hash (select length(Password) from mysql.user where User='youruser')? Is it 16 or 41 bytes long?
[23 Apr 2012 8:42] Kenneth Christensen

The length of the password hash is 16 bytes long.
[23 Apr 2012 9:08] Alexander Soklakov

So, you do use old-style password hash which requires "mysql_old_password" plugin during handshake. Try to replace 16-bytes hash with 41-bytes one (see http://dev.mysql.com/doc/refman/5.5/en/password-hashing.html).
[23 Apr 2012 9:26] Kenneth Christensen
Looks like it's working now, after setting the password to a 41 bytes long hash.

[23 Apr 2012 9:36] Alexander Soklakov
Good, so this is a bug in MysqlOldPasswordPlugin.
[1 May 2012 3:37] John Russell
Added to changelog for 5.1.20: 

Using Connector/J 5.1.19 in combination with JBoss could result in an
error while establishing a connection:
MySQLNonTransientConnectionException: Bad handshake. This issue
occurred when using the old-style password hash, which requires the
mysql_old_password plugin during handshake. A workaround was to
replace the 16-byte hash with a 41-byte one, as explained in .