1

I'm trying to use the sutime python wrapper to make a date normalizer, that would convert any temporal information in strings into dates in the format YYYY-MM-DD. I've created a class, with rules over the sutime outputs to convert the sutime outputs into the standard format as mentioned above. The program is working properly on my local machine, but when i try to run it on a server I get the jpype._jclass.NoClassDefFoundError. The server is on ubuntu with python2, while my local has windows, with python3.

I've tried to implement the solutions to a similar problem on this https://sourceforge.net/p/jpype/discussion/379372/thread/689d7a9b/ forum, but i'm not sure if i was able to implement these soultions correctly. I've also checked that sutime supports both python3 and python2

I think the issue is with jpype or with the sutime library.

This is the traceback that i got
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "date_normalizer.py", line 38, in __init__
    self.sutime = SUTime(jars=self.jar_files, mark_time_ranges=mark_time_ranges)
  File "/home/bridgei2i/.local/lib/python2.7/site-packages/sutime/sutime.py", line 57, in __init__
    'edu.stanford.nlp.python.SUTimeWrapper')
  File "/home/bridgei2i/.local/lib/python2.7/site-packages/jpype/_jclass.py", line 130, in __new__
    return _JClassNew(args[0], **kwargs)
  File "/home/bridgei2i/.local/lib/python2.7/site-packages/jpype/_jclass.py", line 213, in _JClassNew
    javaClass = _jpype.PyJPClass(arg)
jpype._jclass.NoClassDefFoundError: edu/stanford/nlp/python/SUTimeWrapper

2 Answers2

1

Seems likely that the jar file holding edu/stanford/nlp/python/SUTimeWrapper was not found on the server. The specific code that failed was a call to JClass('edu.stanford.nlp.python.SUTimeWrapper') which is a request to load a class from a jar. I would recommend checking the classpath and configuration on the server.

Likely causes are (in order of likelihood)

  1. jar file is not located in the classpath on the server.
  2. The jar file is compiled with a JDK which is newer than runtime environment (though this should generate a different exception).
  3. Some jar file that the class depends on is missing or has the wrong version. (this should produce a different classname in the exception, so it is unlikely.)
  4. A dll for a native portion the jar file is missing or has an incorrect architecture. (rare)

Assuming the jar file is on the server, I would recommend checking the initialization in which the JPype startJVM call is made to see if the path to the jar was correct. It is also possible to examine the loaded classpath using print(jpype.java.lang.System.getProperty('java.class.path')) to see if there is a difference between your local and server machine.

Karl Nelson
  • 336
  • 2
  • 3
0

thank you, as you said:Some jar file that the class depends on is missing or has the wrong version. (this should produce a different classname in the exception, so it is unlikely.)

lvjiujin
  • 501
  • 4
  • 5
  • 1
    Please [edit] to make more obvious which part of this answers the question and how exactly that is meant to be understood. As it is, this post looks much more like a "Thanks" than anything else, but there are hints at an actual answering attempt. So, please elaborate. Otherwise this post might be misunderstood as a pure "Thanks" and be closed for not matching the idea of StackOverflow. If you find actually answering hard, then please use your commenting privilege to turn this into a comment. – Yunnosch Dec 02 '19 at 13:11