8 Replies Latest reply on Apr 27, 2016 2:00 AM by aleks

    mysql datasource in wildfly-10.0.0

    aleks

      I am using wildfly-9.0.2 with mysql datasource and all is working fine.

      Now I try to migrate to wildfly-10.0.0 and get the problem with mysql connection.

      I specify mysql url connection:

       

           <connection-url>jdbc:mysql://mysqlhost.mydomain:3306/mydatabase</connection-url>

       

      but get exception in the wildfly server log:  connection refused.

      As it turned out wildfly can connect to mysql database only if database is working on the

      same host as wildfly, i.e. wildfly always use url

          

           <connection-url>jdbc:mysql://localhost:3306/mydatabase</connection-url>


      Although in web-console on configuration tab I see url


        Connection URL:    jdbc:mysql://mysqlhost.mydomain:3306/mydatabase


      But if I press "test connection" button test is performed on local database.


      What is wrong?


      My configuration:  centos-7.2, jdk 1.8.0_91, wildfly-10.0.0 standalone.xml


        • 1. Re: mysql datasource in wildfly-10.0.0
          mayerw01

          Did you verify that you are able to connect to this database via mysql?

          mysql -h mysqlhost.mydomain mydatabase

          • 2. Re: mysql datasource in wildfly-10.0.0
            aleks

            Yes, I verified it, and it works.

            I can enter the mysql from wildfly server with mysql command.

            There are no any firewall on wildfly or mysql server hosts.

            • 3. Re: mysql datasource in wildfly-10.0.0
              mayerw01

              Did you also try to replace the hostname with the IP-address?

              Which messages do you get in the server.log?

              • 4. Re: mysql datasource in wildfly-10.0.0
                aleks

                Yes, I have tried to replace mysqlhost.mydomain with ip address, but result is the same.

                I have tried also to tcpdump traffic between wildfly and mysqlhost.mydomain hosts during wildfly startup,

                but traffic is absent.

                 

                The exact exception in the server log file is:

                 

                2016-04-26 13:55:44,519 WARN  [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (JCA PoolFiller) IJ000610: Unable to fill pool: javax.resource.ResourceException: IJ031084: Unable to create connection

                    at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:343)

                    at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:350)

                    at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:285)

                    at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.createConnectionEventListener(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:1319)

                    at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.fillTo(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:1135)

                    at org.jboss.jca.core.connectionmanager.pool.mcp.PoolFiller.run(PoolFiller.java:97)

                    at java.lang.Thread.run(Thread.java:745)

                Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

                 

                The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

                    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

                    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

                    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

                    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

                    at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)

                    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:981)

                    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:339)

                    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2253)

                    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2286)

                    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2085)

                    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:795)

                    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)

                    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

                    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

                    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

                    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

                    at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)

                    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:400)

                    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:327)

                    at com.mysql.jdbc.jdbc2.optional.MysqlDataSource.getConnection(MysqlDataSource.java:422)

                    at com.mysql.jdbc.jdbc2.optional.MysqlDataSource.getConnection(MysqlDataSource.java:134)

                    at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:312)

                    ... 6 more

                Caused by: java.net.ConnectException: Connection refused

                    at java.net.PlainSocketImpl.socketConnect(Native Method)

                    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)

                    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)

                    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)

                    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)

                    at java.net.Socket.connect(Socket.java:589)

                    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:211)

                    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:298)

                    ... 21 more

                 

                 

                I must say that if I start wildfly- 9.0.2 server from the same host as wildfly-10.0.0 than all works fine, connection to mysqlhost.mydomain is established.

                • 5. Re: mysql datasource in wildfly-10.0.0
                  mayerw01

                  Did you check your pool settiings?

                  Datasource/jboss.security config issue?

                  • 6. Re: mysql datasource in wildfly-10.0.0
                    aleks

                    standalone.xml:

                     

                                       <pool>

                                            <min-pool-size>20</min-pool-size>

                                            <initial-pool-size>20</initial-pool-size>

                                            <max-pool-size>150</max-pool-size>

                                            <prefill>true</prefill>

                                        </pool>

                     

                    my.cnf:

                                        max_connections=500

                    • 7. Re: mysql datasource in wildfly-10.0.0
                      rcd

                      Does your configuration have datasource-class defined? If yes, then you are probably affected by WFLY-6157. The comments on that issue explain how to fix the problem.

                      • 8. Re: mysql datasource in wildfly-10.0.0
                        aleks

                        I have added to standalone.xml

                         

                                       <connection-property name="ServerName">mysqlhost.mydomain:</connection-property>

                                       <connection-property name="Port">3306</connection-property>

                                       <connection-property name="DatabaseName">mydatabase</connection-property>

                         

                        Now all works. Thanks a lot for help!