SPARQL-Anything / PySPARQL-Anything

The SPARQL Anything Python library
Apache License 2.0
13 stars 2 forks source link

exception thrown when running SPARQL Anything #10

Closed angelosalatino closed 11 months ago

angelosalatino commented 1 year ago

Hi Guys, I have tried to run SPARQL anything onmy laptop and I get the following error. What shall I do?

engine = cli.SparqlAnything()
---------------------------------------------------------------------------
JavaException                             Traceback (most recent call last)
Cell In[3], line 1
----> 1 engine = cli.SparqlAnything()

File ~/anaconda3/envs/py38/lib/python3.8/site-packages/pysparql_anything/sparql_anything.py:20, in SparqlAnything.__init__(self)
     18 def __init__(self):
     19     """ Constructor for the class SparqlAnything."""
---> 20     self.receiver = Engine()

File ~/anaconda3/envs/py38/lib/python3.8/site-packages/pysparql_anything/engine.py:35, in Engine.__init__(self)
     33 """ Constructor for the class Engine. """
     34 location = 'com.github.sparqlanything.cli.SPARQLAnything'
---> 35 self.reflection = autoclass(location)

File ~/anaconda3/envs/py38/lib/python3.8/site-packages/jnius/reflect.py:209, in autoclass(clsname, include_protected, include_private)
    206 cls_start_packagename = '.'.join(clsname.split('.')[:-1])
    208 # c = Class.forName(clsname)
--> 209 c = find_javaclass(clsname)
    210 if c is None:
    211     raise Exception('Java class {0} not found'.format(c))

File jnius/jnius_export_func.pxi:22, in jnius.find_javaclass()

File jnius/jnius_utils.pxi:79, in jnius.check_exception()

JavaException: JVM exception occurred: com/github/sparqlanything/cli/SPARQLAnything java.lang.NoClassDefFoundError
MarcoR1791 commented 1 year ago

Hi Angelo,

The issue is down to the Main class name being changed in the new version of Sparql Anything (0.9-DEV-6) just released. @enridaga is this change intended and permanent?

For a quick fix there are two options.

Either, 1) Download the v0.8.2 jar from here https://github.com/SPARQL-Anything/sparql.anything/releases/tag/v0.8.2 and place it in the pysparql_anything folder of your site-packages,

or

2) Change com --> io in the location variable of the engine.py script. See this snippet of your call stack for the exact location

File ~/anaconda3/envs/py38/lib/python3.8/site-packages/pysparql_anything/engine.py:35, in Engine.__init__(self)
     33 """ Constructor for the class Engine. """
     34 location = 'com.github.sparqlanything.cli.SPARQLAnything'
---> 35 self.reflection = autoclass(location)

The permanent fix is that I need to fix the dependencies and release a new version of the software that handles this compatibility issue.

enridaga commented 1 year ago

I think the problem is that the version downloaded by the python library should not be the latest but the one specific, the v0.8.2 in the case of PySA v0.8.2.1

Also, I think there is a mistake done in flagging one of the dev releases as the latest, maybe we can fix that in the meantime.

enridaga commented 1 year ago

Ok, now the latest release is v0.8.2, all the others are marked as pre releases. Maybe this is sufficient to fix the error? However, I suggest we fix PySA to download a specific, hard coded release.

enridaga commented 1 year ago

OK, the problem is here

https://github.com/SPARQL-Anything/PySPARQL-Anything/blob/180ca7d2c9056c5391a2c09d8d7412edd77315b4/src/pysparql_anything/utilities.py#L31

We should not download the latest version, but a specific version, in the case of the current release, v0.8.2 We can fix the version as a constant in the code, change the method to download the specific artifact, and make an upgrade release of PySA v0.8.2.2

enridaga commented 1 year ago

@angelosalatino it should work now, try with a clean python env or removing and reinstalling the library

angelosalatino commented 1 year ago

Great Thanks. Will let you know.. @ImTanay check on this pls

ImTanay commented 1 year ago

Hi @angelosalatino @enridaga @MarcoR1791 Thanks for the update, will check on this ASAP.

enridaga commented 11 months ago

This now has become urgent because we release 0.9.0 -- thus any new installation of 0.8.1.1 will break!