baztian/jaydebeapi

Error when firebird sql JDBC driver is called

ElCuboNegro opened this issue · 1 comments

Given org.firebirdsql.jdbc.FBDriver driver,
firebird version: org.firebirdsql.jdbc_jaybird-4.0.4.java11.jar
java version: openjdk 11.0.12 2021-07-20 LTS
java runtime: OpenJDK Runtime Environment 18.9 (build 11.0.12+7-LTS)

context:

we try to excecute the following function:

def generate_jaydebeapi_connection(catalog_entry) -> jaydebeapi.Connection:
    driver_class = get_dataset_jdbc_driver(catalog_entry)
    db_url = get_dataset_url(catalog_entry)
    attributes = get_dataset_credentials(catalog_entry)
    driver_path = str(get_driver_file(driver_class))
    
    connection = [catalog_entry, driver_class, db_url, driver_path]
    logging.info("connecting to {}".format(connection))
    
    try:
        connect =  jaydebeapi.connect(driver_class, db_url, attributes, driver_path)
    except Exception as e:
        logging.error(e)
        raise e

the logging shows it gives:
['valid_db_table_name', 'org.firebirdsql.jdbc.FBDriver', "jdbc:firebirdsql://localhost?sqlRole='VALID_ROLE'&encoding=NONE&charSet=ISO-8859-1", 'file://~/jars/org.firebirdsql.jdbc_jaybird-4.0.4.java11.jar']

java.lang.ClassNotFoundException          Traceback (most recent call last)
~/anaconda3/envs/Aldebaran/lib/python3.7/site-packages/_jpype.cpython-37m-x86_64-linux-gnu.so in java.lang.ClassLoader.loadClass()

~/anaconda3/envs/Aldebaran/lib/python3.7/site-packages/_jpype.cpython-37m-x86_64-linux-gnu.so in jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass()

~/anaconda3/envs/Aldebaran/lib/python3.7/site-packages/_jpype.cpython-37m-x86_64-linux-gnu.so in jdk.internal.loader.BuiltinClassLoader.loadClass()

java.lang.ClassNotFoundException: java.lang.ClassNotFoundException: javax.resource.ResourceException

The above exception was the direct cause of the following exception:

Exception                                 Traceback (most recent call last)
~/anaconda3/envs/Aldebaran/lib/python3.7/site-packages/_jpype.cpython-37m-x86_64-linux-gnu.so in org.jpype.manager.TypeManager.findClassByName()

~/anaconda3/envs/Aldebaran/lib/python3.7/site-packages/_jpype.cpython-37m-x86_64-linux-gnu.so in org.jpype.manager.TypeManager.lookupByName()

~/anaconda3/envs/Aldebaran/lib/python3.7/site-packages/_jpype.cpython-37m-x86_64-linux-gnu.so in java.lang.Class.forName()

~/anaconda3/envs/Aldebaran/lib/python3.7/site-packages/_jpype.cpython-37m-x86_64-linux-gnu.so in java.lang.Class.forName0()

Exception: Java Exception

The above exception was the direct cause of the following exception:

java.lang.NoClassDefFoundError            Traceback (most recent call last)
/tmp/ipykernel_3583656/1037870858.py in <module>
----> 1 generate_jaydebeapi_connection("source_hh-COL_MAR-acomodaciones_por_reserva")

/tmp/ipykernel_3583656/4173097476.py in generate_jaydebeapi_connection(catalog_entry)
     12     except Exception as e:
     13         logging.error(e)
---> 14         raise e

/tmp/ipykernel_3583656/4173097476.py in generate_jaydebeapi_connection(catalog_entry)
      9 
     10     try:
---> 11         connect =  jaydebeapi.connect(driver_class, db_url, attributes, driver_path)
     12     except Exception as e:
     13         logging.error(e)

~/anaconda3/envs/Aldebaran/lib/python3.7/site-packages/jaydebeapi/__init__.py in connect(jclassname, url, driver_args, jars, libs)
    410     else:
    411         libs = []
--> 412     jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs)
    413     return Connection(jconn, _converters)
    414 

~/anaconda3/envs/Aldebaran/lib/python3.7/site-packages/jaydebeapi/__init__.py in _jdbc_connect_jpype(jclassname, url, driver_args, jars, libs)
    219             return jpype.JArray(jpype.JByte, 1)(data)
    220     # register driver for DriverManager
--> 221     jpype.JClass(jclassname)
    222     if isinstance(driver_args, dict):
    223         Properties = jpype.java.util.Properties

~/anaconda3/envs/Aldebaran/lib/python3.7/site-packages/jpype/_jclass.py in __new__(cls, jc, loader, initialize)
     97 
     98         # Pass to class factory to create the type
---> 99         return _jpype._getClass(jc)
    100 
    101 

java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: javax/resource/ResourceException```

When called from a development installation (pip install -e ~/jaydebeapi) the error stops happening and it's no longer reproducible.