Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-11067

CONNECT engine table_type=JDBC with ApacheInterface error

Details

    Description

      I have installed Apache DBCP 2 and the pooled library it requires.

      When I try to retrieve table names or column info with Wrapper=ApacheInterface everything works as it should. I can CREATE a connect table with Wrapper=ApacheInterface
      but when I try to SELECT * FROM table that was created like that I get the following error:

      Error Code: 1296. Got error 174 'Connecting: java.lang.NoClassDefFoundError: Could not initialize class org.apache.commons.dbcp2.BasicDataSource rc=0' from CONNECT
      

      It is on the class path because its in the java ext folder. ApacheInterface.class is in a jar file in the ext folder also.

      Not sure if I'm doing something wrong or if its a bug of some sort?

      Attachments

        Activity

          rdyas Robert Dyas added a comment -

          Additional info that might help...

          If I start the server and the first access to the remote server is via ApacheInterface, this is the error message I get:

          Error Code: 1296. Got error 174 'Connecting: java.lang.NoClassDefFoundError: org/apache/commons/dbcp2/BasicDataSource rc=0' from CONNECT
          

          However if I first access the remote server via JdbcInterface (which works correctly) then try the ApacheInterface I get this error message:

          Error Code: 1296. Got error 174 'Connecting: java.lang.NoClassDefFoundError: Could not initialize class org.apache.commons.dbcp2.BasicDataSource rc=0' from CONNECT
          

          Please let me know if there is any additional info I can provide.

          Thank you.

          rdyas Robert Dyas added a comment - Additional info that might help... If I start the server and the first access to the remote server is via ApacheInterface, this is the error message I get: Error Code: 1296 . Got error 174 'Connecting: java.lang.NoClassDefFoundError: org/apache/commons/dbcp2/BasicDataSource rc=0' from CONNECT However if I first access the remote server via JdbcInterface (which works correctly) then try the ApacheInterface I get this error message: Error Code: 1296 . Got error 174 'Connecting: java.lang.NoClassDefFoundError: Could not initialize class org.apache.commons.dbcp2.BasicDataSource rc=0' from CONNECT Please let me know if there is any additional info I can provide. Thank you.
          bertrandop Olivier Bertrand added a comment - - edited

          I cannot reproduce it on Windows. I start the session by:

          set global connect_class_path='postgresql-9.4.1208.jar;E:/Oracle/ojdbc6.jar;E:/Apache/commons-dbcp2-2.1.1/commons-dbcp2-2.1.1.jar;E:/Apache/commons-pool2-2.4.2/commons-pool2-2.4.2.jar;E:/Apache/commons-logging-1.2/commons-logging-1.2.jar;D:/mysql-connector-java-6.0.2/mysql-connector-java-6.0.2-bin.jar;D:/MariaDB-connector-java-1.4.6/mariadb-java-client-1.4.6.jar';
          set global time_zone = '+2:00';
          set connect_java_wrapper='ApacheInterface';
          

          Then access some pre-defined tables:

          select * from jdrv;
          

          Name Version Compliant Description
          org.postgresql.Driver 9.4 No org.postgresql.Driver@1f3c5b5
          oracle.jdbc.OracleDriver 11.2 Yes oracle.jdbc.OracleDriver@17c264
          com.mysql.cj.jdbc.Driver 6.0 No com.mysql.cj.jdbc.Driver@11d72ca
          org.mariadb.jdbc.Driver 1.4 No org.mariadb.jdbc.Driver@98c449

          or:

          CREATE TABLE jboys
          ENGINE=CONNECT CONNECTION='jdbc:mysql://localhost/connect?user=root&useSSL=false' `TABLE_TYPE`='JDBC' `TABNAME`='boys' `OPTION_LIST`='scrollable=1';
          select * from jboys;
          

          name city birth hired
          John Boston 24/01/1986 00:00:00 02/06/2010 00:00:00
          Henry Phoenix 07/06/1987 00:00:00 01/04/2008 00:00:00
          George San Jose 10/08/1981 00:00:00 02/06/2010 00:00:00
          Sam Chicago 21/11/1979 00:00:00 10/10/2007 00:00:00
          James Dallas 13/05/1992 00:00:00 13/12/2009 00:00:00
          Bill Boston 11/09/1986 00:00:00 09/02/2008 00:00:00
          Mat New York 17/07/1975 00:00:00 15/05/2011 00:00:00
          Donald Atlanta 01/04/1999 00:00:00 31/03/2016 00:00:00
          Mick New York 19/01/1980 00:00:00 11/09/2002 00:00:00
          Tom Seatle 14/03/2002 00:00:00 31/12/1969 00:00:00

          To morrow I'll try it on Linux ubuntu

          bertrandop Olivier Bertrand added a comment - - edited I cannot reproduce it on Windows. I start the session by: set global connect_class_path='postgresql-9.4.1208.jar;E:/Oracle/ojdbc6.jar;E:/Apache/commons-dbcp2-2.1.1/commons-dbcp2-2.1.1.jar;E:/Apache/commons-pool2-2.4.2/commons-pool2-2.4.2.jar;E:/Apache/commons-logging-1.2/commons-logging-1.2.jar;D:/mysql-connector-java-6.0.2/mysql-connector-java-6.0.2-bin.jar;D:/MariaDB-connector-java-1.4.6/mariadb-java-client-1.4.6.jar'; set global time_zone = '+2:00'; set connect_java_wrapper='ApacheInterface'; Then access some pre-defined tables: select * from jdrv; Name Version Compliant Description org.postgresql.Driver 9.4 No org.postgresql.Driver@1f3c5b5 oracle.jdbc.OracleDriver 11.2 Yes oracle.jdbc.OracleDriver@17c264 com.mysql.cj.jdbc.Driver 6.0 No com.mysql.cj.jdbc.Driver@11d72ca org.mariadb.jdbc.Driver 1.4 No org.mariadb.jdbc.Driver@98c449 or: CREATE TABLE jboys ENGINE=CONNECT CONNECTION='jdbc:mysql://localhost/connect?user=root&useSSL=false' `TABLE_TYPE`='JDBC' `TABNAME`='boys' `OPTION_LIST`='scrollable=1'; select * from jboys; name city birth hired John Boston 24/01/1986 00:00:00 02/06/2010 00:00:00 Henry Phoenix 07/06/1987 00:00:00 01/04/2008 00:00:00 George San Jose 10/08/1981 00:00:00 02/06/2010 00:00:00 Sam Chicago 21/11/1979 00:00:00 10/10/2007 00:00:00 James Dallas 13/05/1992 00:00:00 13/12/2009 00:00:00 Bill Boston 11/09/1986 00:00:00 09/02/2008 00:00:00 Mat New York 17/07/1975 00:00:00 15/05/2011 00:00:00 Donald Atlanta 01/04/1999 00:00:00 31/03/2016 00:00:00 Mick New York 19/01/1980 00:00:00 11/09/2002 00:00:00 Tom Seatle 14/03/2002 00:00:00 31/12/1969 00:00:00 To morrow I'll try it on Linux ubuntu
          rdyas Robert Dyas added a comment - - edited

          I was not aware that the commons-logging was required. I had commons-dbcp2 and commons-pool2 but not the commons-logging... and the tell tale class name was cut off in the error message. Once I added commons-logging to the classpath it worked perfectly

          Unless I missed it, maybe you can update the documentation to state that ApacheInterface needs 3 libs:
          commons-dbcp2
          commons-pool2
          commons-logging

          Also, how do I configure the connection pool without writing a custom ApacheInterface class?

          On to stress testing, then onto pilot testing. Zero crashes so far (very unlike the ODBC experience where a bad driver interactions could take down the entire MariaDB server - has not happened once yet with JDBC... just a nice mostly clean error message).

          rdyas Robert Dyas added a comment - - edited I was not aware that the commons-logging was required. I had commons-dbcp2 and commons-pool2 but not the commons-logging... and the tell tale class name was cut off in the error message. Once I added commons-logging to the classpath it worked perfectly Unless I missed it, maybe you can update the documentation to state that ApacheInterface needs 3 libs: commons-dbcp2 commons-pool2 commons-logging Also, how do I configure the connection pool without writing a custom ApacheInterface class? On to stress testing, then onto pilot testing. Zero crashes so far (very unlike the ODBC experience where a bad driver interactions could take down the entire MariaDB server - has not happened once yet with JDBC... just a nice mostly clean error message).

          how do I configure the connection pool without writing a custom ApacheInterface class?
          Good question. The current Apache wrapper is very basic and provides nothing for further configuration. Configure parameters are listed in:
          http://commons.apache.org/proper/commons-dbcp/configuration.html
          but I did not find examples showing how to implement them (the links to samples are broken)
          Any suggestion or help is warmly welcome!

          bertrandop Olivier Bertrand added a comment - how do I configure the connection pool without writing a custom ApacheInterface class ? Good question. The current Apache wrapper is very basic and provides nothing for further configuration. Configure parameters are listed in: http://commons.apache.org/proper/commons-dbcp/configuration.html but I did not find examples showing how to implement them (the links to samples are broken) Any suggestion or help is warmly welcome!
          rdyas Robert Dyas added a comment -

          looking at the 2.1.1 BasicDataSource api docs:

          Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is not the only way to combine the commons-dbcp and commons-pool packages, but provides a "one stop shopping" solution for basic requirements.

          public void setConnectionProperties(String connectionProperties)
          Sets the connection properties passed to driver.connect(...). Format of the string must be [propertyName=property;]* NOTE - The "user" and "password" properties will be added explicitly, so they do not need to be included here.
          Parameters:
          connectionProperties - the connection properties used to create new connections
          

          I'm not sure but maybe this is the answer?

          rdyas Robert Dyas added a comment - looking at the 2.1.1 BasicDataSource api docs: Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is not the only way to combine the commons-dbcp and commons-pool packages, but provides a "one stop shopping" solution for basic requirements. public void setConnectionProperties(String connectionProperties) Sets the connection properties passed to driver.connect(...). Format of the string must be [propertyName=property;]* NOTE - The "user" and "password" properties will be added explicitly, so they do not need to be included here. Parameters: connectionProperties - the connection properties used to create new connections I'm not sure but maybe this is the answer?
          bertrandop Olivier Bertrand added a comment - - edited

          From what I understand setConnectionProperties is not used to configure the basicDataSource itself but to send property settings to the driver used by the connection. I have tried a test by enabling settings connection properties via a new create option, for example:

          CREATE TABLE jboys
          ENGINE=CONNECT  TABLE_TYPE=JDBC TABNAME='boys' 
          CONNECTION='jdbc:mysql://localhost/connect?user=root'
          OPTION_LIST='properties=maxRows=5;useSSL=false';
          

          The property list (here maxRows=5;useSSL=false) is passed to the ApacheInterface as a fifth parameter and when it is not null, is used as the parameter of setConnectionProperties that send them to the MySQL driver.
          I checked in debug mode that it is indeed executed and it works.
          Does this answer your question and should I implement it?
          However, it might be useless because it is simpler to do:

          CREATE TABLE jboys
          ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME='boys'
          CONNECTION='jdbc:mysql://localhost/connect?user=root&maxRows=5&useSSL=false';
          

          Unlike the first solution, this one works as well with the Apache or MySQL wrappers.

          bertrandop Olivier Bertrand added a comment - - edited From what I understand setConnectionProperties is not used to configure the basicDataSource itself but to send property settings to the driver used by the connection. I have tried a test by enabling settings connection properties via a new create option, for example: CREATE TABLE jboys ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME='boys' CONNECTION='jdbc:mysql://localhost/connect?user=root' OPTION_LIST='properties=maxRows=5;useSSL=false'; The property list (here maxRows=5;useSSL=false) is passed to the ApacheInterface as a fifth parameter and when it is not null, is used as the parameter of setConnectionProperties that send them to the MySQL driver. I checked in debug mode that it is indeed executed and it works. Does this answer your question and should I implement it? However, it might be useless because it is simpler to do: CREATE TABLE jboys ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME='boys' CONNECTION='jdbc:mysql://localhost/connect?user=root&maxRows=5&useSSL=false'; Unlike the first solution, this one works as well with the Apache or MySQL wrappers.
          rdyas Robert Dyas added a comment -

          I agree, don't implement as its redundant.
          I think this ticket can be closed as the ApacheInterface error just requires a tweak to the documentation as noted above. Anything else I come across I'll open as a different ticket.
          Thank you!

          rdyas Robert Dyas added a comment - I agree, don't implement as its redundant. I think this ticket can be closed as the ApacheInterface error just requires a tweak to the documentation as noted above. Anything else I come across I'll open as a different ticket. Thank you!
          bertrandop Olivier Bertrand added a comment - - edited

          I have updated the documentation to indicate precisely what jar files are needed when using the Apache interface.

          bertrandop Olivier Bertrand added a comment - - edited I have updated the documentation to indicate precisely what jar files are needed when using the Apache interface.

          People

            bertrandop Olivier Bertrand
            rdyas Robert Dyas
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.