Custom Keyword using Java and importing to RIDE

Hi All,

I had started to build a custom keyword from Java and created a JAR file so that it can be used in RIDE as keyword. Now that I am able to create a JAR file, I am not sure on how to import the JAR to RIDE and use the keywords in a test case.
Can anyone help me on providing the detailed steps on how to import them or a detailed documentation if available could help me understand it better.

Thanks.

First, clarify what is the problem.

  • RIDE shows import in red color:
    1. There are failed import errors in Tools->RIDE Log
    2. The execution in command window/shell/terminal does not work
  • The execution in command window/shell/terminal works without errors

Thank you so much for replying. I highly appreciate your immediate response for the query.
I would like to explain the whole process which I had followed in the attempt of trying to use a method/keyword from a Java class.

Python version – 2.7.15
PIP – 9.0.3
Robot Framework – 3.2.1
Jython – 2.7.0

Created a java project with a class and few public methods and then created a JAR file by exporting the same.
Placed the JAR in C:\Python27\Scripts path and as well as in C:\Python27\Lib\site-packages.

For importing the JAR File, tried few ways which weren’t of help to me:

  1. Found in this link that we are supposed to create a Library spec through libdoc tool or by using Jython.
    https://github.com/robotframework/RIDE/wiki/Keyword-Completion#setting-pythonpath
    Tired to install libdoc tool from the below given URL which was found from the same blog mentioned above - https://code.google.com/archive/p/robotframework/wikis/LibraryDocumentationTool.wiki, but was not able to install the same as its throwing error(Error: 404).
  2. Tried to install Jython, but not sure on how to proceed with the creation of spec after that. Basically, we were not aware of creating the spec for a Java based library.
  3. Not sure how to add the spec file to PYTHONPATH as we are stuck in the above mentioned point itself.
  4. In the RIDE tool, created a test suite and then clicked on Add Import’s (Library). Gave the class name (fully qualified name) as org.robot.sample.keywords.SampleKeywordLibrary in the Name part. Clicked on Ok. Also tried specifying only the jar file’s name.

After adding the same, found that the library added is highlighted in “Red” color which I understand that the Import is unsuccessful.
Found the Failed error logs in RIDE’s Log:

Importing test library ‘SampleKeywordLibrary’ failed: Not a valid file or directory to import.
File “C:\Python27\lib\site-packages\robotide\spec\librarymanager.py”, line 87, in _fetch_keywords
return get_import_result(path, library_args)
File “C:\Python27\lib\site-packages\robotide\spec\libraryfetcher.py”, line 24, in get_import_result
lib = robotapi.TestLibrary(path, args)
File “C:\Python27\lib\site-packages\robotide\lib\robot\running\testlibraries.py”, line 50, in TestLibrary
return_source=True)
File “C:\Python27\lib\site-packages\robotide\lib\robot\utils\importer.py”, line 72, in import_class_or_module
self._raise_import_failed(name, err)
File “C:\Python27\lib\site-packages\robotide\lib\robot\utils\importer.py”, line 103, in _raise_import_failed
raise DataError(msg)

I would like to know if we have added the JAR in the required places and Can we directly use this jar or we need to create spec – I f yes then how?

It would be much helpful If you could let us know at point we are going wrong and with the steps to resolve the same.

The reference is always our User Guide, look for Java.

It is OK for RIDE not seeing the documentation, of a library that does not documentation prepared. Libdoc is part of Robot Framework.

You will have to install Robot Framework on Jython, that would be a separate install from Python.

The best way to confirm the environment is correctly setup, is to run the SwingLibrary demo. After that, you can setup documentation in RIDE and confirm it is also correctly set.

You may use the run profile jybot but you have to create your own jybot script or batch, because is no longer installed with Robot Framework.

Hi, Thank you for clarifying few doubts on the installation of Robot Framework in Jython.
We were able to install Robot Framework on Jython with the command:
jython -m pip install robotframework

For ensuring if the environment is correctly set for RIDE, we downloaded the SwingLibrary jar from
https://mvnrepository.com/artifact/org.robotframework/swinglibrary/1.9.9

We had the class path set by placing the jar file in C:\Python27\Lib\site-packages.
In CLASSPATH:
C:\Python27\Scripts;C:\Python27\Lib\site-packages;

We then tried to import the library in Ride Tool by adding the relative path (…/…/Python27/Lib/site-packages/swingLibrary1.9.9.jar) as well as by giving the directory name as (SwingLibrary).
Even though we had it both ways, the import is still highlighted in “red” color.
image
Found the below mentioned details in the Log:

  1. 20200717 17:43:02.310 [WARN]: Importing test library “C:\robotFramework\LibrarayTest…/…/Python27/Lib/site-packages/swinglibrary-demo/lib/swinglibrary-1.2.jar” failed
    Traceback (most recent call last):
    Importing test library ‘C:\robotFramework\LibrarayTest…\Python27\Lib\site-packages\swinglibrary-demo\lib\swinglibrary-1.2.jar’ failed: Not a valid file or directory to import.
    File “C:\Python27\lib\site-packages\robotide\spec\librarymanager.py”, line 87, in _fetch_keywords
    return get_import_result(path, library_args)
    File “C:\Python27\lib\site-packages\robotide\spec\libraryfetcher.py”, line 24, in get_import_result
    lib = robotapi.TestLibrary(path, args)
    File “C:\Python27\lib\site-packages\robotide\lib\robot\running\testlibraries.py”, line 50, in TestLibrary
    return_source=True)
    File “C:\Python27\lib\site-packages\robotide\lib\robot\utils\importer.py”, line 72, in import_class_or_module
    self._raise_import_failed(name, err)
    File “C:\Python27\lib\site-packages\robotide\lib\robot\utils\importer.py”, line 103, in _raise_import_failed
    raise DataError(msg)

  2. 20200717 17:44:09.440 [WARN]: Importing test library “swinglibrary-demo” failed
    Traceback (most recent call last):
    Importing test library ‘swinglibrary-demo’ failed: ImportError: No module named swinglibrary-demo
    Traceback (most recent call last):
    File “C:\Python27\lib\site-packages\robotide\lib\robot\utils\importer.py”, line 153, in _import
    return import(name, fromlist=fromlist)
    PYTHONPATH:
    C:\WINDOWS\system32\python27.zip
    C:\Python27\DLLs
    C:\Python27\lib
    C:\Python27\lib\plat-win
    C:\Python27\lib\lib-tk
    C:\Python27
    C:\Python27\lib\site-packages
    C:\Python27\lib\site-packages\win32
    C:\Python27\lib\site-packages\win32\lib
    C:\Python27\lib\site-packages\Pythonwin
    C:\Python27\lib\site-packages\wx-2.8-msw-unicode
    C:\Python27\lib\site-packages\robotide\spec
    C:\Python27\lib\site-packages\robotide\lib
    C:\Python27\lib\site-packages\robotide\contrib\testrunner…/…/lib
    C:\Python27\lib\site-packages\robotide\contrib\testrunner…/…/lib
    File “C:\Python27\lib\site-packages\robotide\spec\librarymanager.py”, line 87, in _fetch_keywords
    return get_import_result(path, library_args)
    File “C:\Python27\lib\site-packages\robotide\spec\libraryfetcher.py”, line 24, in get_import_result
    lib = robotapi.TestLibrary(path, args)
    File “C:\Python27\lib\site-packages\robotide\lib\robot\running\testlibraries.py”, line 50, in TestLibrary
    return_source=True)
    File “C:\Python27\lib\site-packages\robotide\lib\robot\utils\importer.py”, line 72, in import_class_or_module
    self._raise_import_failed(name, err)
    File “C:\Python27\lib\site-packages\robotide\lib\robot\utils\importer.py”, line 109, in _raise_import_failed
    raise DataError(’\n’.join(msg))

  3. 20200717 17:58:47.456 [WARN]: Importing test library “C:\robotFramework\LibrarayTest…/…/Python27/Lib/site-packages/swinglibrary-1.9.9.jar” failed
    Traceback (most recent call last):
    Importing test library ‘C:\robotFramework\LibrarayTest…\Python27\Lib\site-packages\swinglibrary-1.9.9.jar’ failed: Not a valid file or directory to import.
    File “C:\Python27\lib\site-packages\robotide\spec\librarymanager.py”, line 87, in _fetch_keywords
    return get_import_result(path, library_args)
    File “C:\Python27\lib\site-packages\robotide\spec\libraryfetcher.py”, line 24, in get_import_result
    lib = robotapi.TestLibrary(path, args)
    File “C:\Python27\lib\site-packages\robotide\lib\robot\running\testlibraries.py”, line 50, in TestLibrary
    return_source=True)
    File “C:\Python27\lib\site-packages\robotide\lib\robot\utils\importer.py”, line 72, in import_class_or_module
    self._raise_import_failed(name, err)
    File “C:\Python27\lib\site-packages\robotide\lib\robot\utils\importer.py”, line 103, in _raise_import_failed
    raise DataError(msg)

And one more doubt regarding jybot which you have mentioned. How exactly is jybot used in RIDE and how to create a jybot script or batch if necessary.

We have tried out three different methods of giving the Library to RIDE, but all three are giving 3 different errors.
How should I be resolving this issue and then start using the custom keyword JAR?

You have to try to run the demo from command window.
The example is very clear, the import is:
Library SwingLibrary

I think this will do for jybot.bat (which must be found in a directory in PATH):

@echo off
set CLASSPATH=C:\jython2.7.2\Lib\site-packages\swinglibrary-1.9.9.jar
jython -m robot    %*

NOTE: I have just tested that jybot command and the file must be .bat not .cmd (because of RIDE implementation). Also because of new RIDE only work on Python 3, the log and progress of tests would not work. Maybe you don’t have this problem with RIDE version 1.7.4.2 in Python 2.7.
New NOTE: I confirm that with RIDE version 1.7.4.2 in Python 2.7, running status and log are OK.

I really appreciate your patience in helping us by providing steps to make this work. Thank you for replying on the same.

I tried out your comments and used https://github.com/robotframework/SwingLibrary/blob/master/demo/example.txt in RIDE.
Ensured that the swinglibrary-1.9.9.jar is present in the site-packages directory of jython2.7.2 folder - C:\jython2.7.2\Lib\site-packages
Created a jybot.bat script with

@echo off
set CLASSPATH=C:\jython2.7.2\Lib\site-packages\swinglibrary-1.9.9.jar
jython -m robot %*

Below is the screenshot of the directory where we have placed the library’s JAR and the jybot.bat script.
image
Next step which is followed is that in the RIDE, I had set the Execution Profile to jybot and executing the test cases.

But, I was not able to execute its successfully. It was throwing a NoClassDefFoundError error.
Below is the Error Message after trying to execute the Swing Library Demo.

command: jybot.bat --argumentfile c:\users\ah0161759.hewitt-na\appdata\local\temp\RIDEy63nbo.d\argfile.txt --listener C:\Python27\lib\site-packages\robotide\contrib\testrunner\TestRunnerAgent.py:62397:False C:\robotFramework\LibrarayTest
TestRunnerAgent: Running under Jython 2.7.2

=====================================================================================================================================================================
LibrarayTest

[ ERROR ] Error in file ‘C:\robotFramework\LibrarayTest’ on line 2: Importing test library ‘SwingLibrary’ failed: NoClassDefFoundError: org/robotframework/javalib/library/KeywordDocumentationRepository
java.lang.NoClassDefFoundError:
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at robot.utils.importer$py.import$16(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/importer.py:188)
at robot.utils.importer$py.call_function(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/importer.py)
at robot.utils.importer$py.import
$31(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/importer.py:283)
at robot.utils.importer$py.call_function(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/importer.py)
at robot.utils.importer$py._import_class_or_module$5(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/importer.py:77)
at robot.utils.importer$py.call_function(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/importer.py)
at robot.utils.importer$py.import_class_or_module$4(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/importer.py:74)
at robot.utils.importer$py.call_function(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/importer.py)
at robot.model.visitor$py.visit_suite$2(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/model/visitor.py:89)
at robot.model.visitor$py.call_function(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/model/visitor.py)
at robot.model.testsuite$py.visit$21(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/model/testsuite.py:174)
at robot.model.testsuite$py.call_function(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/model/testsuite.py)
at robot.run$py.main$3(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/run.py:452)
at robot.run$py.call_function(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/run.py)
at robot.utils.application$py._execute$10(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/application.py:94)
at robot.utils.application$py.call_function(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/application.py)
at robot.utils.application$py.execute_cli$5(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/application.py:49)
at robot.utils.application$py.call_function(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/application.py)
at robot.run$py.run_cli$7(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/run.py:492)
at robot.run$py.call_function(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/run.py)
at runpy$py._run_code$9(C:/jython2.7.2/Lib/runpy.py:73)
at runpy$py.call_function(C:/jython2.7.2/Lib/runpy.py)
at runpy$py._run_module_as_main$14(C:/jython2.7.2/Lib/runpy.py:161)
at runpy$py.call_function(C:/jython2.7.2/Lib/runpy.py)
Caused by: java.lang.ClassNotFoundException: org.robotframework.javalib.library.KeywordDocumentationRepository
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
… 194 more
PYTHONPATH:
C:\jython2.7.2\Lib
classpath
pyclasspath/
C:\jython2.7.2\Lib\site-packages
C:\Python27\lib\site-packages\robotide\contrib\testrunner…/…/lib
CLASSPATH:
C:\jython2.7.2\jython.jar
C:\jython2.7.2\Lib\site-packages\swinglibrary-1.9.9.jar
LibrarayTest.UpointTest

[ ERROR ] Error in file ‘C:\robotFramework\LibrarayTest\UpointTest.robot’ on line 3: Importing test library ‘SwingLibrary’ failed: NoClassDefFoundError: org/robotframework/javalib/library/KeywordDocumentationRepository
java.lang.NoClassDefFoundError:
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at robot.utils.importer$py.import$16(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/importer.py:188)
at robot.utils.importer$py.call_function(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/importer.py)
at robot.utils.importer$py.import
$31(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/importer.py:283)
at robot.utils.importer$py.call_function(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/importer.py)
at robot.utils.importer$py._import_class_or_module$5(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/importer.py:77)
at robot.utils.importer$py.call_function(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/importer.py)
at robot.utils.importer$py.import_class_or_module$4(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/importer.py:74)
at robot.utils.importer$py.call_function(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/importer.py)
at robot.model.visitor$py.visit_suite$2(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/model/visitor.py:89)
at robot.model.visitor$py.call_function(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/model/visitor.py)
at robot.model.testsuite$py.visit$21(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/model/testsuite.py:174)
at robot.model.testsuite$py.call_function(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/model/testsuite.py)
at robot.model.itemlist$py.visit$12(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/model/itemlist.py:76)
at robot.model.itemlist$py.call_function(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/model/itemlist.py)
at robot.model.visitor$py.visit_suite$2(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/model/visitor.py:89)
at robot.model.visitor$py.call_function(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/model/visitor.py)
at robot.model.testsuite$py.visit$21(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/model/testsuite.py:174)
at robot.model.testsuite$py.call_function(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/model/testsuite.py)
at robot.run$py.main$3(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/run.py:452)
at robot.run$py.call_function(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/run.py)
at robot.utils.application$py._execute$10(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/application.py:94)
at robot.utils.application$py.call_function(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/application.py)
at robot.utils.application$py.execute_cli$5(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/application.py:49)
at robot.utils.application$py.call_function(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/utils/application.py)
at robot.run$py.run_cli$7(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/run.py:492)
at robot.run$py.call_function(C:/Users/ah0161759.HEWITT-NA/AppData/Local/Temp/pip-install-vaqw8t/robotframework/robot/run.py)
at runpy$py._run_code$9(C:/jython2.7.2/Lib/runpy.py:73)
at runpy$py.call_function(C:/jython2.7.2/Lib/runpy.py)
at runpy$py._run_module_as_main$14(C:/jython2.7.2/Lib/runpy.py:161)
at runpy$py.call_function(C:/jython2.7.2/Lib/runpy.py)
Caused by: java.lang.ClassNotFoundException: org.robotframework.javalib.library.KeywordDocumentationRepository
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
… 212 more
PYTHONPATH:
C:\jython2.7.2\Lib
classpath
pyclasspath/
C:\jython2.7.2\Lib\site-packages
C:\Python27\lib\site-packages\robotide\contrib\testrunner…/…/lib
CLASSPATH:
C:\jython2.7.2\jython.jar
C:\jython2.7.2\Lib\site-packages\swinglibrary-1.9.9.jar
Test Add Todo Item | FAIL |
Parent suite setup failed:
No keyword with name ‘Start Test Application’ found.

LibrarayTest.UpointTest | FAIL |
Suite setup failed:
No keyword with name ‘Start Test Application’ found.

1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed

LibrarayTest | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed

Output: c:\users\ah0161759.hewitt-na\appdata\local\temp\RIDEy63nbo.d\output.xml
Log: c:\users\ah0161759.hewitt-na\appdata\local\temp\RIDEy63nbo.d\log.html
Report: c:\users\ah0161759.hewitt-na\appdata\local\temp\RIDEy63nbo.d\report.html

Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:“C:\Program Files (x86)\HP\Unified Functional Testing\bin\java_shared\classes”;“C:\Program Files (x86)\HP\Unified Functional Testing\bin\java_shared\classes\jasmine.jar”

test finished 20200720 14:19:01

Could you please help us resolve this issue as we have created the jbot.bat script and placed the library’s jar file in the required directory.

Thanks,
Apoorva A

Below is the screenshot of RIDE, which has the Execution Profile set to “jybot”
image
Thanks,
Apoorva A

Can’t tell much. I suspect of two things.
The robotframework installed is 3.2.1 not 3.1.2. Uninstall robotframework and install again with fixed version.

Try to use the demo, just like it is on project, run from command window outside RIDE.
The demo has a run_demo.py which is not working correctly. Confirm that you have Java 8 working OK by running the demo app:

set CLASSPATH=C:\jython2.7.2\Lib\site-packages\swinglibrary-1.9.9.jar
java org.robotframework.swing.testapp.examplesut.TodoListApplication

But running jybot example.txt should work.
After this setup is confirmed, you can try RIDE.

Do you mean that we need to have the version of Robot Framework as 3.1.2 and not 3.2.1. Is 3.1.2 a fixed version?
And we are able to run the demo app using the commands which were provided by you in command prompt. Thus we can confirm that Java 8 is working fine.

I think so, because 3.2.1 have a different core code, and your error suggests me that.

Do:

jython -m pip install -U --force robotframework==3.1.2

Hi, Thanks for suggesting the same. We tried to use the command
jython -m pip install -U --force robotframework==3.1.2
But we are getting the below error when we try the same:
image
Can you please help us on the same.

Why you say it is the same problem?
This is a totally different problem. It has to deal with Java certificates.

In my experiments I had problems when using newer pip. After searching the net, I got that the best version for jython, would be around 9. So, I installed pip 9.?? in jython and could install the intended versions of packages.

We found that in Jython (2.7.2) the version of PIP being used is 19.1. And that is why we had an issue with the installation of Robot Frame work in Jython.
image
Could you please help us out in this downgrading of PIP version from 19.1 to 9.?

Option1:

  1. Delete all pip* folders inside jython’s Lib\Site-packages
  2. Run jython -m ensurepip
  3. If all went well, you now have pip~=1.0 or other
  4. Install newer pip with jython -m pip install --upgrade pip==9.0.3

Option2:

  1. Delete all pip* folders inside jython’s Lib\Site-packages
  2. Download and extract pip version 9.0.3 on some temporary directory
  3. Install newer pip with jython setup.py install

We are now able to use the PIP 9.0.3 in Jython by following the steps mentioned. And now, tried to install Robot Framework in Jython with the PIP version of 9.0.3.

But still, we are facing the same issue which was already faced while trying to install Robot Framework in Jython using the command:
jython -m pip install -U --force robotframework==3.1.2

Below is the error which was throwing when we executed the command:

C:\Users\ah0161759.HEWITT-NA>jython -m pip install -U --force robotframework==3.
1.2
Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:“C:\Program Files (x86)
HP\Unified Functional Testing\bin\java_shared\classes”;“C:\Program Files (x86)\H
P\Unified Functional Testing\bin\java_shared\classes\jasmine.jar”
Collecting robotframework==3.1.2
←[31mException:
Traceback (most recent call last):
File “pyclasspath/pip/basecommand.py”, line 215, in main
status = self.run(options, args)
File “pyclasspath/pip/commands/install.py”, line 324, in run
requirement_set.prepare_files(finder)
File “pyclasspath/pip/commands/install.py”, line 324, in run
requirement_set.prepare_files(finder)
File “pyclasspath/pip/req/req_set.py”, line 376, in prepare_files
discovered_reqs.extend(self._prepare_file(
File “pyclasspath/pip/req/req_set.py”, line 376, in prepare_files
discovered_reqs.extend(self._prepare_file(
File “pyclasspath/pip/req/req_set.py”, line 551, in _prepare_file
req_to_install.populate_link(
File “pyclasspath/pip/req/req_install.py”, line 278, in populate_link
self.link = finder.find_requirement(self, upgrade)
File “pyclasspath/pip/index.py”, line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File “pyclasspath/pip/index.py”, line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File “pyclasspath/pip/index.py”, line 568, in _get_pages
page = self._get_page(location)
File “pyclasspath/pip/index.py”, line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File “pyclasspath/pip/index.py”, line 788, in get_page
resp = session.get(
File “pyclasspath/pip/index.py”, line 788, in get_page
resp = session.get(
File “pyclasspath/pip/_vendor/requests/sessions.py”, line 521, in get
return self.request(‘GET’, url, **kwargs)
File “pyclasspath/pip/download.py”, line 386, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File “pyclasspath/pip/_vendor/requests/sessions.py”, line 508, in request
resp = self.send(prep, **send_kwargs)
File “pyclasspath/pip/_vendor/requests/sessions.py”, line 618, in send
r = adapter.send(request, kwargs)
File “pyclasspath/pip/_vendor/cachecontrol/adapter.py”, line 47, in send
resp = super(CacheControlAdapter, self).send(request, kw)
File “pyclasspath/pip/_vendor/requests/adapters.py”, line 407, in send
self.cert_verify(conn, request.url, verify, cert)
File “pyclasspath/pip/_vendor/requests/adapters.py”, line 225, in cert_ver
ify
raise IOError("Could not find a suitable TLS CA certificate bundle, "
IOError: Could not find a suitable TLS CA certificate bundle, invalid path: py
classpath
/pip/_vendor/certifi\cacert.pem←[0m
←[33mYou are using pip version 9.0.3
, however version 20.1.1 is available.

You should consider upgrading via the ‘pip install --upgrade pip’ command.←[0m

Can you please help us on the same as we are having the correct version of PIP installed now in Jython.

Thanks.

To bypass certificates problem, download the .zip package from PyPi, from this URL: https://pypi.org/project/robotframework/3.1.2/#files

Then install from the package:
jython -m pip install -U --force robotframework-3.1.2.zip

You could try to install directly with (but the same certificate problem may happen):
jython -m pip install -U --force https://files.pythonhosted.org/packages/6c/04/2aee0fb807e14d2f2463217f81ac94c542b5b0c5809a7535f284a0bbb05c/robotframework-3.1.2.zip

I am not sure if jython/pip would support the use of .whl files, so I propose the .zip.

Thank you so much for spending your valuable time in exchanging your ideas and ways to make this work.

We tried to install the robot framework 3.1.2 successfully by following the steps mentioned above.

We are also able to run the demo app by using the command which you had provided:

set CLASSPATH=C:\jython2.7.2\Lib\site-packages\swinglibrary-1.9.9.jar
java org.robotframework.swing.testapp.examplesut.TodoListApplication

which confirms that we have Java 8 working OK.
Now that we have all of them in place, we tried to use the SwingLibrary in RIDE, but the library is not being recognized when we try to use the same.

Would you mind if we could set up a connect for this issue so that it will be very helpful for us to understand and resolve this issue.

Thanks.

Hope you tried to run the demo test, from command window and from RIDE, to see it is working.

About the red color for SwingLibrary in RIDE, you fix that by importing the documentation XML, you get from https://github.com/robotframework/SwingLibrary/releases.

Have fun :slight_smile:

Yes we have tried running the demo test from command window as well as in RIDE. We were able to execute the same in command window.

While we executed in RIDE by setting the Execution Profile to Jybot and we got the following error message:

[ ERROR ] Error in file ‘C:\robotFramework\LibrarayTest\TestLib’: Importing test library ‘SwingLibrary’ failed: NoClassDefFoundError: org/robotframework/javalib/library/KeywordDocumentationRepository
java.lang.NoClassDefFoundError: **
** at java.lang.ClassLoader.defineClass1(Native Method)

** at java.lang.ClassLoader.defineClass(Unknown Source)**
** at java.security.SecureClassLoader.defineClass(Unknown Source)**
** at java.net.URLClassLoader.defineClass(Unknown Source)**
** at java.net.URLClassLoader.access$100(Unknown Source)**
** at java.net.URLClassLoader$1.run(Unknown Source)**
** at java.net.URLClassLoader$1.run(Unknown Source)**
** at java.security.AccessController.doPrivileged(Native Method)**
** at java.net.URLClassLoader.findClass(Unknown Source)**
** at java.lang.ClassLoader.loadClass(Unknown Source)**
** at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)**
** at java.lang.ClassLoader.loadClass(Unknown Source)**
** at java.lang.ClassLoader.defineClass1(Native Method)**
** at java.lang.ClassLoader.defineClass(Unknown Source)**
** at java.security.SecureClassLoader.defineClass(Unknown Source)**
** at java.net.URLClassLoader.defineClass(Unknown Source)**
** at java.net.URLClassLoader.access$100(Unknown Source)**
** at java.net.URLClassLoader$1.run(Unknown Source)**
** at java.net.URLClassLoader$1.run(Unknown Source)**
** at java.security.AccessController.doPrivileged(Native Method)**
** at java.net.URLClassLoader.findClass(Unknown Source)**
** at java.lang.ClassLoader.loadClass(Unknown Source)**
** at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)**
** at java.lang.ClassLoader.loadClass(Unknown Source)**
** at java.lang.ClassLoader.loadClass(Unknown Source)**
** at java.lang.Class.forName0(Native Method)**
** at java.lang.Class.forName(Unknown Source)**
** at robot.utils.importer$py.import$14(C:/jython2.7.2/Lib/site-packages/robot/utils/importer.py:167)**
** at robot.utils.importer$py.call_function(C:/jython2.7.2/Lib/site-packages/robot/utils/importer.py)**
** at robot.utils.importer$py.import
$29(C:/jython2.7.2/Lib/site-packages/robot/utils/importer.py:257)**
** at robot.utils.importer$py.call_function(C:/jython2.7.2/Lib/site-packages/robot/utils/importer.py)**
** at robot.utils.importer$py._import_class_or_module$5(C:/jython2.7.2/Lib/site-packages/robot/utils/importer.py:77)**
** at robot.utils.importer$py.call_function(C:/jython2.7.2/Lib/site-packages/robot/utils/importer.py)**
** at robot.utils.importer$py.import_class_or_module$4(C:/jython2.7.2/Lib/site-packages/robot/utils/importer.py:74)**
** at robot.utils.importer$py.call_function(C:/jython2.7.2/Lib/site-packages/robot/utils/importer.py)**
** at robot.model.visitor$py.visit_suite$2(C:/jython2.7.2/Lib/site-packages/robot/model/visitor.py:88)**
** at robot.model.visitor$py.call_function(C:/jython2.7.2/Lib/site-packages/robot/model/visitor.py)**
** at robot.model.testsuite$py.visit$19(C:/jython2.7.2/Lib/site-packages/robot/model/testsuite.py:168)**
** at robot.model.testsuite$py.call_function(C:/jython2.7.2/Lib/site-packages/robot/model/testsuite.py)**
** at robot.run$py.main$3(C:/jython2.7.2/Lib/site-packages/robot/run.py:448)**
** at robot.run$py.call_function(C:/jython2.7.2/Lib/site-packages/robot/run.py)**
** at robot.utils.application$py._execute$10(C:/jython2.7.2/Lib/site-packages/robot/utils/application.py:94)**
** at robot.utils.application$py.call_function(C:/jython2.7.2/Lib/site-packages/robot/utils/application.py)**
** at robot.utils.application$py.execute_cli$5(C:/jython2.7.2/Lib/site-packages/robot/utils/application.py:49)**
** at robot.utils.application$py.call_function(C:/jython2.7.2/Lib/site-packages/robot/utils/application.py)**
** at robot.run$py.run_cli$7(C:/jython2.7.2/Lib/site-packages/robot/run.py:488)**
** at robot.run$py.call_function(C:/jython2.7.2/Lib/site-packages/robot/run.py)**
** at runpy$py._run_code$9(C:/jython2.7.2/Lib/runpy.py:73)**
** at runpy$py.call_function(C:/jython2.7.2/Lib/runpy.py)**
** at runpy$py._run_module_as_main$14(C:/jython2.7.2/Lib/runpy.py:161)**
** at runpy$py.call_function(C:/jython2.7.2/Lib/runpy.py)**
Caused by: java.lang.ClassNotFoundException: org.robotframework.javalib.library.KeywordDocumentationRepository
** at java.net.URLClassLoader.findClass(Unknown Source)**
** at java.lang.ClassLoader.loadClass(Unknown Source)**
** at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)**
** at java.lang.ClassLoader.loadClass(Unknown Source)**
** … 194 more**
PYTHONPATH:
** C:\jython2.7.2\Lib**
** classpath**
** pyclasspath/**
** C:\jython2.7.2\Lib\site-packages**
** C:\Python27\lib\site-packages\robotide\contrib\testrunner…/…/lib**
CLASSPATH:
** C:\jython2.7.2\jython.jar**
** C:\jython2.7.2\Lib\site-packages\swinglibrary-1.9.9.jar**
=========================================================================================================================================================================
**TestLib **
=========================================================================================================================================================================
**TestLib.UpointTest **
=========================================================================================================================================================================

[ ERROR ] Error in file ‘C:\robotFramework\LibrarayTest\TestLib\UpointTest.robot’: Importing test library ‘SwingLibrary’ failed: NoClassDefFoundError: org/robotframework/javalib/library/KeywordDocumentationRepository
java.lang.NoClassDefFoundError: **
** at java.lang.ClassLoader.defineClass1(Native Method)

** at java.lang.ClassLoader.defineClass(Unknown Source)**
** at java.security.SecureClassLoader.defineClass(Unknown Source)**
** at java.net.URLClassLoader.defineClass(Unknown Source)**
** at java.net.URLClassLoader.access$100(Unknown Source)**
** at java.net.URLClassLoader$1.run(Unknown Source)**
** at java.net.URLClassLoader$1.run(Unknown Source)**
** at java.security.AccessController.doPrivileged(Native Method)**
** at java.net.URLClassLoader.findClass(Unknown Source)**
** at java.lang.ClassLoader.loadClass(Unknown Source)**
** at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)**
** at java.lang.ClassLoader.loadClass(Unknown Source)**
** at java.lang.ClassLoader.defineClass1(Native Method)**
** at java.lang.ClassLoader.defineClass(Unknown Source)**
** at java.security.SecureClassLoader.defineClass(Unknown Source)**
** at java.net.URLClassLoader.defineClass(Unknown Source)**
** at java.net.URLClassLoader.access$100(Unknown Source)**
** at java.net.URLClassLoader$1.run(Unknown Source)**
** at java.net.URLClassLoader$1.run(Unknown Source)**
** at java.security.AccessController.doPrivileged(Native Method)**
** at java.net.URLClassLoader.findClass(Unknown Source)**
** at java.lang.ClassLoader.loadClass(Unknown Source)**
** at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)**
** at java.lang.ClassLoader.loadClass(Unknown Source)**
** at java.lang.ClassLoader.loadClass(Unknown Source)**
** at java.lang.Class.forName0(Native Method)**
** at java.lang.Class.forName(Unknown Source)**
** at robot.utils.importer$py.import$14(C:/jython2.7.2/Lib/site-packages/robot/utils/importer.py:167)**
** at robot.utils.importer$py.call_function(C:/jython2.7.2/Lib/site-packages/robot/utils/importer.py)**
** at robot.utils.importer$py.import
$29(C:/jython2.7.2/Lib/site-packages/robot/utils/importer.py:257)**
** at robot.utils.importer$py.call_function(C:/jython2.7.2/Lib/site-packages/robot/utils/importer.py)**
** at robot.utils.importer$py._import_class_or_module$5(C:/jython2.7.2/Lib/site-packages/robot/utils/importer.py:77)**
** at robot.utils.importer$py.call_function(C:/jython2.7.2/Lib/site-packages/robot/utils/importer.py)**
** at robot.utils.importer$py.import_class_or_module$4(C:/jython2.7.2/Lib/site-packages/robot/utils/importer.py:74)**
** at robot.utils.importer$py.call_function(C:/jython2.7.2/Lib/site-packages/robot/utils/importer.py)**
** at robot.model.visitor$py.visit_suite$2(C:/jython2.7.2/Lib/site-packages/robot/model/visitor.py:88)**
** at robot.model.visitor$py.call_function(C:/jython2.7.2/Lib/site-packages/robot/model/visitor.py)**
** at robot.model.testsuite$py.visit$19(C:/jython2.7.2/Lib/site-packages/robot/model/testsuite.py:168)**
** at robot.model.testsuite$py.call_function(C:/jython2.7.2/Lib/site-packages/robot/model/testsuite.py)**
** at robot.model.itemlist$py.visit$11(C:/jython2.7.2/Lib/site-packages/robot/model/itemlist.py:71)**
** at robot.model.itemlist$py.call_function(C:/jython2.7.2/Lib/site-packages/robot/model/itemlist.py)**
** at robot.model.visitor$py.visit_suite$2(C:/jython2.7.2/Lib/site-packages/robot/model/visitor.py:88)**
** at robot.model.visitor$py.call_function(C:/jython2.7.2/Lib/site-packages/robot/model/visitor.py)**
** at robot.model.testsuite$py.visit$19(C:/jython2.7.2/Lib/site-packages/robot/model/testsuite.py:168)**
** at robot.model.testsuite$py.call_function(C:/jython2.7.2/Lib/site-packages/robot/model/testsuite.py)**
** at robot.run$py.main$3(C:/jython2.7.2/Lib/site-packages/robot/run.py:448)**
** at robot.run$py.call_function(C:/jython2.7.2/Lib/site-packages/robot/run.py)**
** at robot.utils.application$py._execute$10(C:/jython2.7.2/Lib/site-packages/robot/utils/application.py:94)**
** at robot.utils.application$py.call_function(C:/jython2.7.2/Lib/site-packages/robot/utils/application.py)**
** at robot.utils.application$py.execute_cli$5(C:/jython2.7.2/Lib/site-packages/robot/utils/application.py:49)**
** at robot.utils.application$py.call_function(C:/jython2.7.2/Lib/site-packages/robot/utils/application.py)**
** at robot.run$py.run_cli$7(C:/jython2.7.2/Lib/site-packages/robot/run.py:488)**
** at robot.run$py.call_function(C:/jython2.7.2/Lib/site-packages/robot/run.py)**
** at runpy$py._run_code$9(C:/jython2.7.2/Lib/runpy.py:73)**
** at runpy$py.call_function(C:/jython2.7.2/Lib/runpy.py)**
** at runpy$py._run_module_as_main$14(C:/jython2.7.2/Lib/runpy.py:161)**
** at runpy$py.call_function(C:/jython2.7.2/Lib/runpy.py)**
Caused by: java.lang.ClassNotFoundException: org.robotframework.javalib.library.KeywordDocumentationRepository
** at java.net.URLClassLoader.findClass(Unknown Source)**
** at java.lang.ClassLoader.loadClass(Unknown Source)**
** at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)**
** at java.lang.ClassLoader.loadClass(Unknown Source)**
** … 212 more**
PYTHONPATH:
** C:\jython2.7.2\Lib**
** classpath**
** pyclasspath/**
** C:\jython2.7.2\Lib\site-packages**
** C:\Python27\lib\site-packages\robotide\contrib\testrunner…/…/lib**
CLASSPATH:
** C:\jython2.7.2\jython.jar**
** C:\jython2.7.2\Lib\site-packages\swinglibrary-1.9.9.jar**
Utest | PASS |
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TestLib.UpointTest | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
=========================================================================================================================================================================
TestLib | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
=========================================================================================================================================================================
Output: c:\users\ah0161759.hewitt-na\appdata\local\temp\RIDEwic1cs.d\output.xml
Log: c:\users\ah0161759.hewitt-na\appdata\local\temp\RIDEwic1cs.d\log.html
Report: c:\users\ah0161759.hewitt-na\appdata\local\temp\RIDEwic1cs.d\report.html

Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:“C:\Program Files (x86)\HP\Unified Functional Testing\bin\java_shared\classes”;"C:\Program Files (x86)\HP\Unified Functional Testing\bin\java_shared\classes\jasmine.jar"

test finished 20200722 18:09:26

Even though it is showing Red colour in the Import section, we executed and got the above error.

Secondly, we are able to download the documentation XML. Could you please let us know at what path should the XML File be placed exactly or how should we import the XML?

Thanks.