[MDEV-31015] MariaDB Connect JavaWrappers.Jar not found Created: 2023-04-05  Updated: 2023-05-29  Resolved: 2023-05-23

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - Connect
Affects Version/s: 10.11.2
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Adrian Alonzo Assignee: Anel Husakovic
Resolution: Not a Bug Votes: 0
Labels: None
Environment:

Ubuntu Docker Image


Attachments: PNG File mariadb-screenshot.PNG     PNG File screenshot-1.png     PNG File screenshot-2.png    
Issue Links:
Relates
relates to MDEV-26218 connect engine JDBC on Debian 10 miss... Stalled
relates to MDBF-559 Create blog: Connect SE JDBC table ty... Closed

 Description   

I have a docker container which includes MariaDB v10.11, openjdk 8, ,MariaDB Connect and Javawrapper and java connector 8.

The docker image is created like so:

FROM mariadb:10.11
 
RUN apt update \
    && apt install openjdk-8-jdk -y \
    && export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 \
    && apt install curl -y
 
RUN curl -LsS https://r.mariadb.com/downloads/mariadb_repo_setup | bash -s -- --mariadb-server-version="mariadb-10.11"
 
RUN apt install mariadb-plugin-connect -y
    
COPY JavaWrappers.jar /usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/
COPY mariadb-java-client-3.1.3.jar /usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/
# Additionally copy to plugin location
COPY JavaWrappers.jar /usr/lib/mysql/plugin/
COPY mariadb-java-client-3.1.3.jar /usr/lib/mysql/plugin/
COPY ./connect.cnf /etc/mysql/mariadb.conf.d/connect.cnf
RUN chmod 0444 /etc/mysql/mariadb.conf.d/connect.cnf

It includes the Java Connector (Java 8 Connector v3.1.3) and Java Wrapper from MDEV-1093.

Using this container image I ran two instances of MariaDB to test and migrate data from MariaDB to MariaDB using the following procedures:

On MariaDB Image One:
Create sample data

create table sample (bloodType varchar(100) not null);
INSERT INTO sample (bloodType) VALUES ("O"), ("A"), ("AB");

On MariaDB Image Two:
Use Connect Engine To Migrate Data From Server One to Two

create table sample_server1 (
  bloodType varchar(100) not null)
engine=CONNECT table_type=JDBC
connection='jdbc:mariadb://10.50.6.101:3306/test?user=root&password=r00t';
 
create table sample like sample_server1;
set global connect_jvm_path="/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server";
alter table sample engine=InnoDB;

Upon the last line I am greeted with the following error:

MariaDB [test]> alter table sample engine=InnoDB;
ERROR 1296 (HY000): Got error 174 'ERROR: class /usr/lib/mysql/plugin/JavaWrappers.jar not found!' from CONNECT

As a sanity check I checked the directory to ensure server 2 has the necessary jar files including JavaWrappers.jar as shown in the attached screenshot. Why is this failing?



 Comments   
Comment by Adrian Alonzo [ 2023-04-05 ]

I should also note my docker deployment has a connect.cnf defined as the following:

[mariadb]
plugin-load-add=ha_connect.so
 
connect_jvm_path=”/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/amd64/server”
connect_class_path=”/usr/lib/mysql/plugin:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/”

Comment by Daniel Black [ 2023-04-05 ]

The error "ERROR 1296 (HY000): Got error 174 'ERROR: class /usr/lib/mysql/plugin/JavaWrappers.jar not found!' from CONNECT" is from the failed env->findClass which according to the Java classloader API takes a binary name and not a jar path file which is what it is called with.

Looking at the connect test cases connect_class_path is set to include the JavaWrappers.jar file which might work around the problem.

Note on your Dockerfile, "mariadb_repo_setup" isn't needed. The MariaDB repos are already configured in the container, after apt-get update, the mariadb-plugin-connect is installable. The lack of packaging of JavaWrappers.jar is MDEV-26218.

So three bugs:

  • lack of packaging of JavaWrappers.jar - MDEV-26218
  • poor Connect code attemps to load the JarWrappers.jar file as a class, which generates a confusing error message (this bug)
  • user/documentation error, connect_class_path should include the JavaWrappers.jar file.
Comment by Adrian Alonzo [ 2023-04-05 ]

Hi Daniel,

With that in mind I've attempted to change the connect_class_path to attempt a work around in the mean time.

I've tried the following two cases: include the jar file and include the jar folder. Unfortunately, both resulting in the same error.

MariaDB [test]> set global connect_class_path="/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/JavaWrappers.jar:/usr/lib/mysql/plugin";
MariaDB [test]> alter table sample engine=InnoDB;
ERROR 1296 (HY000): Got error 174 'ERROR: class wrappers/JdbcInterface not found!' from CONNECT

MariaDB [test]> set global connect_class_path="/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext:/usr/lib/mysql/plugin";
MariaDB [test]> alter table sample engine=InnoDB;
ERROR 1296 (HY000): Got error 174 'ERROR: class wrappers/JdbcInterface not found!' from CONNECT

Comment by Daniel Black [ 2023-04-06 ]

Upon closer examination the error is different. I suspect it needs https://github.com/MariaDB/server/blob/10.11/storage/connect/mysql-test/connect/std_data/JdbcMariaDB.jar in the connect_class_path too.

Comment by Adrian Alonzo [ 2023-04-10 ]

Good morning.

I included the JdbcMariaDB. jar file in the directory usr/lib/mysql/plugin as seen below:

I then set the globals to include JdbcMariaDB.jar. But I get the same error.

set global connect_class_path="usr/lib/mysql/plugin/JavaWrappers.jar:usr/lib/mysql/plugin/JdbcMariaDB.jar:/usr/lib/mysql/plugin";
MariaDB [test]> alter table sample engine=InnoDB;
ERROR 1296 (HY000): Got error 174 'ERROR: class wrappers/JdbcInterface not found!' from CONNECT

Comment by Adrian Alonzo [ 2023-04-12 ]

It seems like this is a debian related issue. In the mean time do you think I can bypass this issue by creating a dockerfile for rockylinux and executing mariadb connect from there instead?

Comment by Daniel Black [ 2023-04-12 ]

I think the issue based on your screen shot is there is no global read permissions on the jar files in the /usr/lib/mysql/plugins directory and they are root owned. MariaDB is starting as the mysql user so won't be able to read these.

I checked the jar file and the class is there.

jar -tvf JdbcMariaDB.jar | more
  2510 Sun Nov 27 14:29:38 SGT 2016 META-INF/MANIFEST.MF
     0 Thu Nov 24 18:33:48 SGT 2016 wrappers/
  2245 Thu Nov 24 18:33:48 SGT 2016 wrappers/MariadbInterface.class
  2238 Thu Nov 24 18:33:48 SGT 2016 wrappers/OracleInterface.class
  2286 Thu Nov 24 18:33:48 SGT 2016 wrappers/PostgresqlInterface.class
 17099 Thu Nov 24 18:33:48 SGT 2016 wrappers/JdbcInterface.class
  2304 Thu Nov 24 18:33:48 SGT 2016 wrappers/ApacheInterface.class
  5375 Thu Nov 24 18:33:48 SGT 2016 wrappers/Client.class
  2233 Thu Nov 24 18:33:48 SGT 2016 wrappers/MysqlInterface.class
  1776 Sat Jul 16 23:03:00 SGT 2016 wrappers/HikariCPInterface.Copie
...

Comment by Adrian Alonzo [ 2023-04-13 ]

Good point. I provided read and changed ownership to mysql:

chown -R mysql:mysql /usr/lib/mysql/plugin
chmod o+r /usr/lib/mysql/plugin/*.jar
chown -R mysql:mysql /usr/lib/mysql

I now arrive at a different error.

MariaDB [test]> set global connect_class_path="/usr/lib/mysql/pluginJavaWrappers.jar:/usr/lib/mysql/pluginJdbcMariaDB.jar:/usr/lib/mysql/plugin";
Query OK, 0 rows affected (0.000 sec)
 
MariaDB [test]> alter table sample engine=InnoDB;
ERROR 1296 (HY000): Got error 174 'ERROR: class /usr/lib/mysql/plugin/ not found!' from CONNECT

Alternatively, I tried to only include the jar files but the same error occured. " set global connect_class_path="/usr/lib/mysql/pluginJavaWrappers.jar:/usr/lib/mysql/pluginJdbcMariaDB.jar"

I found this page which details how to check classpath. Checking classpath I get null. Is this another issue?

MariaDB [test]> create function envar returns string soname 'ha_connect.so';
Query OK, 0 rows affected (0.008 sec)
 
MariaDB [test]> select envar('CLASSPATH');
+--------------------+
| envar('CLASSPATH') |
+--------------------+
| NULL               |
+--------------------+

Comment by Anel Husakovic [ 2023-04-14 ]

Hi,
before we start let's check do you have loaded connect SE, run select plugin_name from information_schema.plugins where plugin_name='connect';.
If it is loaded, restart your container docker restart <cont-name>.
What you should do are following steps:
1. check jvm file path
2. check Javawrapper.jar file path
and make sure they are correct, I suppose this is not correct from your configuration "/usr/lib/mysql/pluginJavaWrappers.jar", missing `/`, right ?
After that:
3. check the path of you JDBC mariadb client
4. add it to your class path connect_class_path together with Javawrapper.jar file
5. don't care about envar('classpath')
6. try example from documentation to create the table with {{mariadb}}JDBC and proper authentication. It should work.
If doesn't work please add results from all above steps to debug.

Comment by Adrian Alonzo [ 2023-04-27 ]

Hello. Thanks for the reply. The "/" was a typo but correcting it had similar results. So I followed your instructions to ensure it was correct. Im using Kubernetes with Helm so after checking whether connect was installed I restarted with the following:

# restarting pod from current directory
restart helm upgrade --recreate-pods -i my-maria-a .

MariaDB [test]>  select plugin_name from information_schema.plugins where plugin_name='connect';
+-------------+
| plugin_name |
+-------------+
| CONNECT     |
+-------------+

1. check jvm file path

root@my-maria-b-deployment-7dd78565d9-r7mcq:/# echo $JAVA_HOME
 
root@my-maria-b-deployment-7dd78565d9-r7mcq:/# which java
/usr/bin/java
root@my-maria-b-deployment-7dd78565d9-r7mcq:/# readlink -f /usr/bin/java
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
root@my-maria-b-deployment-7dd78565d9-r7mcq:/usr/lib/mysql/plugin# set global connect_jvm_path="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java:/usr/lib/mysql/plugin";

2. check Javawrapper.jar file path and check the path of you JDBC mariadb client

root@my-maria-b-deployment-7dd78565d9-r7mcq:/usr/lib/mysql/plugin# ll /usr/lib/mysql/plugin/*.jar
-rw-r--r-- 1 mysql mysql   44053 Apr  4 22:47 /usr/lib/mysql/plugin/JavaWrappers.jar
-rw-r--r-- 1 mysql mysql 6021947 Apr 10 16:24 /usr/lib/mysql/plugin/JdbcMariaDB.jar
-rw-r--r-- 1 mysql mysql  638356 Apr  4 17:44 /usr/lib/mysql/plugin/mariadb-java-client-3.1.3.jar

3. check the path of you JDBC mariadb client

root@my-maria-b-deployment-7dd78565d9-r7mcq:/usr/lib/mysql/plugin# set global connect_class_path="/usr/lib/mysql/plugin/JavaWrappers.jar:/usr/lib/mysql/plugin/mariadb-java-client-3.1.3.jar";

The example below was an adaptation from the docs (although I cannot find the link). It is similar to the SO instructions in the answer.

MariaDB [test]> drop table sample;
Query OK, 0 rows affected (0.005 sec)
 
MariaDB [test]> drop table sample_server1;
Query OK, 0 rows affected (0.004 sec)
 
MariaDB [test]> create table sample_server1 ( bloodType varchar(100) not null) engine=CONNECT table_type=JDBC connection='jdbc:mariadb://10.50.6.101:3306/test?user=root&password=r00t';
Query OK, 0 rows affected (0.017 sec)
 
MariaDB [test]> create table sample like sample_server1;
Query OK, 0 rows affected (0.003 sec)
 
MariaDB [test]> alter table sample engine=InnoDB;
ERROR 1296 (HY000): Got error 174 'ERROR: class /usr/lib/mysql/plugin/ not found!' from CONNECT

Comment by Anel Husakovic [ 2023-05-23 ]

Hi,
so you can create successfully table using JDBC, what was the purpose of MDEV right.

Regarding your additional error, I couldn't reproduce it.

  • Source:

    MariaDB [db_maria]> create table sample (bloodType varchar(100) not null);
    Query OK, 0 rows affected (0.028 sec)
    MariaDB [db_maria]> INSERT INTO sample (bloodType) VALUES ("O"), ("A"), ("AB");
    MariaDB [db_maria]> select * from sample;
    +-----------+
    | bloodType |
    +-----------+
    | O         |
    | A         |
    | AB        |
    +-----------+
    

  • Target:

    MariaDB [test]> create table target_sample engine=connect table_type=JDBC tabname=sample connection='jdbc:mariadb://mariadb-source/db_maria?user=root&password';
    Query OK, 0 rows affected (0.014 sec)
     
    MariaDB [test]> select * from target_sample;
    +-----------+
    | bloodType |
    +-----------+
    | O         |
    | A         |
    | AB        |
    +-----------+
    3 rows in set (0.003 sec)
     
    MariaDB [test]> create table target_sample_innodb like target_sample;
    Query OK, 0 rows affected (0.020 sec)
     
    MariaDB [test]> select * from target_sample_innodb;
    +-----------+
    | bloodType |
    +-----------+
    | O         |
    | A         |
    | AB        |
    +-----------+
    3 rows in set (0.003 sec)
    

    Soon, we will publish the blog related to the JDBC and Connect.
    Feel free to create new MDEV related to new error, I will close this one .

Comment by Anel Husakovic [ 2023-05-29 ]

Here is the blog post about https://mariadb.org/connect-se-jdbc-table-type-accessing-tables-from-another-dbms/

Generated at Thu Feb 08 10:20:38 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.