Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JayDeBeApi throws AttributeError: '_jpype.PyJPField' object has no attribute 'getStaticAttribute' #99

Closed
FlippieZ opened this issue Jun 25, 2019 · 16 comments

Comments

@FlippieZ
Copy link

FlippieZ commented Jun 25, 2019

Screenshot 2019-06-25 at 12 59 11

This error is returned when JayDeBeApi is used with the latest version of JPype (0.7.0).
With the previous version of JPype (0.6.3) no problem.

We use JayDeBeApi in our Databricks environment which installs by default the latest JPype version. Overriding this with 0.6.3 version solves the problem.

@rolweber
Copy link

rolweber commented Jul 1, 2019

See section "Direct access to private fields" here:
jpype-project/jpype#498

@grahamplace
Copy link

Had the exact same issue — confirmed that pinning JPype (0.6.3) resolved for me as well.

@EmileSonneveld
Copy link

Pinning JPype worked for me too pip install JPype1==0.6.3 --force-reinstall

@dlbeswick
Copy link

Hello, just a note that I've tested with current master (52a7da5) and the issue is fixed for me.

@devarti
Copy link

devarti commented Sep 19, 2019

This - pip install JPype1==0.6.3 --force-reinstall worked.

@byrdman062
Copy link

I am using Python 3.7 through Anaconda. I am unable to force the Jpype1 to 0.6.3. In Jupyter I get the following:

C:\Users\ab7y91\AppData\Local\Continuum\anaconda3\lib\site-packages\jpype1-0.7.0-py3.7-win-amd64.egg\jpype_core.py:210: UserWarning:

Deprecated: convertStrings was not specified when starting the JVM. The default
behavior in JPype will be False starting in JPype 0.8. The recommended setting
for new code is convertStrings=False. The legacy value of True was assumed for
this session. If you are a user of an application that reported this warning,
please file a ticket with the developer.

How do I change this within the module? Or is there another solution than the one mentioned above?

jstoja added a commit to jstoja/integrations-core that referenced this issue Nov 25, 2019
Oracle integration uses jaydebeapi==1.1.1 and jpype1==0.7.0 python packages that are uncompatible.
jaydebeapi==1.1.2 release address this issue.
- baztian/jaydebeapi#99
- https://github.com/baztian/jaydebeapi#changelog
jstoja added a commit to jstoja/integrations-core that referenced this issue Nov 25, 2019
Oracle integration uses jaydebeapi==1.1.1 and jpype1==0.7.0 python packages that are uncompatible.
jaydebeapi==1.1.2 release address this issue.
- baztian/jaydebeapi#99
- https://github.com/baztian/jaydebeapi#changelog
@tadtenacious
Copy link

I am using Python 3.7 through Anaconda. I am unable to force the Jpype1 to 0.6.3. In Jupyter I get the following:

C:\Users\ab7y91\AppData\Local\Continuum\anaconda3\lib\site-packages\jpype1-0.7.0-py3.7-win-amd64.egg\jpype_core.py:210: UserWarning:

Deprecated: convertStrings was not specified when starting the JVM. The default

behavior in JPype will be False starting in JPype 0.8. The recommended setting
for new code is convertStrings=False. The legacy value of True was assumed for
this session. If you are a user of an application that reported this warning,
please file a ticket with the developer.
How do I change this within the module? Or is there another solution than the one mentioned above?

I just ran into this too after installation, I was able to downgrade JPype1 this way:
(venv) conda install -c conda-forge JPype1=0.6.3 --force-reinstall
Seems to work now.

@ghost
Copy link

ghost commented Jan 16, 2020

I used the “pip install JPype1==0.6.3 --force-reinstall” solution EmileSonneveld mentioned and it resolved my issue when I ran the code locally. However, I was trying to deploy my code to AWS Lambda using Jenkins. When I installed JayDeBeApi it relied on JPype1 and installed the 0.7.1 version. I then did a pip installed JPype1 version 0.6.3 using EmileSonneveld’s solution. When my code ran on Lambda it utilized the 0.7.1 version of JPype1. I was able to resolve this issue by putting the JPype1 install ahead of the JayDeBeApi install in my requirements.txt file as:
jpype1==0.6.3
JayDeBeApi

@manyi613
Copy link

I used the “pip install JPype1==0.6.3 --force-reinstall” solution EmileSonneveld mentioned and it resolved my issue when I ran the code locally. However, I was trying to deploy my code to AWS Lambda using Jenkins. When I installed JayDeBeApi it relied on JPype1 and installed the 0.7.1 version. I then did a pip installed JPype1 version 0.6.3 using EmileSonneveld’s solution. When my code ran on Lambda it utilized the 0.7.1 version of JPype1. I was able to resolve this issue by putting the JPype1 install ahead of the JayDeBeApi install in my requirements.txt file as:
jpype1==0.6.3
JayDeBeApi

i have same question, btw, i hope use python 3.8 in my test,but JayDeBeApi is not support as well, follow this issue. wish this problem sovled quickly.

@joseplar
Copy link

Installed jaydebeapi two days ago, I had the same incompatibility issue with jpype 0.7.0, I had to downgrade jpype to 0.6.3. And jpype 0.6.3 is incompatible with latest python 3.8.1, so also had to downgrade python to 3.7.6.
These is what I had to install to make it work:
jaydebeapi 1.1.1
jpype1 0.6.3
python 3.7.6

@manyi613
Copy link

manyi613 commented Feb 3, 2020

Installed jaydebeapi two days ago, I had the same incompatibility issue with jpype 0.7.0, I had to downgrade jpype to 0.6.3. And jpype 0.6.3 is incompatible with latest python 3.8.1, so also had to downgrade python to 3.7.6.
These is what I had to install to make it work:
jaydebeapi 1.1.1
jpype1 0.6.3
python 3.7.6

i ues this version on Windows 10 ,but i have fatal exception

Testing started at 21:05 ...
F:\pycharm\test37\Scripts\python.exe "F:\pycharm\PyCharm 2018.2.4\helpers\pycharm\_jb_pytest_runner.py" --target test_ldb.py::test_simple
Launching pytest with arguments test_ldb.py::test_simple in E:\workspace\test37

============================= test session starts =============================
platform win32 -- Python 3.7.6, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
rootdir: E:\workspace\test37collected 1 item

test_ldb.py Windows fatal exception: access violation

Current thread 0x000023a4 (most recent call first):
  File "F:\pycharm\test37\lib\site-packages\jpype\_core.py", line 70 in startJVM
  File "F:\pycharm\test37\lib\site-packages\jaydebeapi\__init__.py", line 176 in _jdbc_connect_jpype
  File "F:\pycharm\test37\lib\site-packages\jaydebeapi\__init__.py", line 381 in connect
  File "E:\workspace\test37\test_ldb.py", line 12 in connect
  File "E:\workspace\test37\test_ldb.py", line 18 in test_simple
  File "F:\pycharm\test37\lib\site-packages\_pytest\python.py", line 167 in pytest_pyfunc_call
  File "F:\pycharm\test37\lib\site-packages\pluggy\callers.py", line 187 in _multicall
  File "F:\pycharm\test37\lib\site-packages\pluggy\manager.py", line 87 in <lambda>
  File "F:\pycharm\test37\lib\site-packages\pluggy\manager.py", line 93 in _hookexec
  File "F:\pycharm\test37\lib\site-packages\pluggy\hooks.py", line 286 in __call__
  File "F:\pycharm\test37\lib\site-packages\_pytest\python.py", line 1445 in runtest
  File "F:\pycharm\test37\lib\site-packages\_pytest\runner.py", line 134 in pytest_runtest_call
  File "F:\pycharm\test37\lib\site-packages\pluggy\callers.py", line 187 in _multicall
  File "F:\pycharm\test37\lib\site-packages\pluggy\manager.py", line 87 in <lambda>
  File "F:\pycharm\test37\lib\site-packages\pluggy\manager.py", line 93 in _hookexec
  File "F:\pycharm\test37\lib\site-packages\pluggy\hooks.py", line 286 in __call__
  File "F:\pycharm\test37\lib\site-packages\_pytest\runner.py", line 210 in <lambda>
  File "F:\pycharm\test37\lib\site-packages\_pytest\runner.py", line 237 in from_call
  File "F:\pycharm\test37\lib\site-packages\_pytest\runner.py", line 210 in call_runtest_hook
  File "F:\pycharm\test37\lib\site-packages\_pytest\runner.py", line 185 in call_and_report
  File "F:\pycharm\test37\lib\site-packages\_pytest\runner.py", line 99 in runtestprotocol
  File "F:\pycharm\test37\lib\site-packages\_pytest\runner.py", line 84 in pytest_runtest_protocol
  File "F:\pycharm\test37\lib\site-packages\pluggy\callers.py", line 187 in _multicall
  File "F:\pycharm\test37\lib\site-packages\pluggy\manager.py", line 87 in <lambda>
  File "F:\pycharm\test37\lib\site-packages\pluggy\manager.py", line 93 in _hookexec
  File "F:\pycharm\test37\lib\site-packages\pluggy\hooks.py", line 286 in __call__
  File "F:\pycharm\test37\lib\site-packages\_pytest\main.py", line 271 in pytest_runtestloop
  File "F:\pycharm\test37\lib\site-packages\pluggy\callers.py", line 187 in _multicall
  File "F:\pycharm\test37\lib\site-packages\pluggy\manager.py", line 87 in <lambda>
  File "F:\pycharm\test37\lib\site-packages\pluggy\manager.py", line 93 in _hookexec
  File "F:\pycharm\test37\lib\site-packages\pluggy\hooks.py", line 286 in __call__
  File "F:\pycharm\test37\lib\site-packages\_pytest\main.py", line 247 in _main
  File "F:\pycharm\test37\lib\site-packages\_pytest\main.py", line 197 in wrap_session
  File "F:\pycharm\test37\lib\site-packages\_pytest\main.py", line 240 in pytest_cmdline_main
  File "F:\pycharm\test37\lib\site-packages\pluggy\callers.py", line 187 in _multicall
  File "F:\pycharm\test37\lib\site-packages\pluggy\manager.py", line 87 in <lambda>
  File "F:\pycharm\test37\lib\site-packages\pluggy\manager.py", line 93 in _hookexec
  File "F:\pycharm\test37\lib\site-packages\pluggy\hooks.py", line 286 in __call__
  File "F:\pycharm\test37\lib\site-packages\_pytest\config\__init__.py", line 93 in main
  File "F:\pycharm\PyCharm 2018.2.4\helpers\pycharm\_jb_pytest_runner.py", line 31 in <module>

@hunnifer
Copy link

In the def of _jdbc_connect_jpype within the __init__ method, there used to be code to establish the version of jpype. If it was "old" (pre 0.7), the method getStaticAttribute was used to make a types map, otherwise (post v0.7) __get__ was used. Restoring this code lets me get on with my database linkup:


    if hasattr(jpype, '__version__'):
        try:
            ver_match = re.match('\d+\.\d+', jpype.__version__)
            if ver_match:
                jpype_ver = float(ver_match.group(0))
                if jpype_ver < 0.7:
                    old_jpype = True
                else:
                    old_jpype = False
        except ValueError:
            pass

types_map = {}
        for i in types.__javaclass__.getClassFields():
            if old_jpype:
                types_map[i.getName()] = i.getStaticAttribute()
            else:
                types_map[i.getName()] = i.__get__(i)
        _init_types(types_map)
'''

@jmskarda
Copy link

@hunnifer's solution worked for me too. However, instead of restoring the whole code block I just corrected the incorrect call. Should work fine unless JPype ver < 0.7.

\jaydebeapi\init.py (~ Line 183)

            # types_map[i.getName()] = i.getStaticAttribute()  # Original incorrect call
            types_map[i.getName()] = i.__get__(i) # Corrected call

@gantir
Copy link

gantir commented Mar 6, 2020

This - pip install JPype1==0.6.3 --force-reinstall worked.

I too got things working with this workaround. Is a proper fix for this issue available?

@srmds
Copy link

srmds commented Mar 24, 2020

Forcing a reinstall of the old version JPype1==0.6.3 is not an option for me, because JPype1 0.7.0 contain essential fixes, mainly for this reason. Therefore, would like to have the compatibility of JayDeBeApi with JPype version >0.7.*

How to fix this, without downgrading JPype1?

@baztian
Copy link
Owner

baztian commented May 22, 2020

Should be fixed in the current version

@baztian baztian closed this as completed May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests