rainmanwy / robotframework-SikuliLibrary

Sikuli Robot Framework Library provide keywords for Robot Framework to test UI through Sikuli.
Apache License 2.0
147 stars 61 forks source link

java.lang.ExceptionInInitializerError: null in ubantu 23.10 #190

Closed JerryXinhui closed 4 months ago

JerryXinhui commented 6 months ago

I can't run my sikuli robotframework test case with following script.

environment:

system: Ubantu
uname -r
6.5.0-28-generic

Distributor ID: Ubuntu
Description:    Ubuntu 23.10
Release:    23.10
Codename:   mantic

java version:
I tried java_8 and java_17 and java_11 both cannot work
python version:3.9
robotframework-SikuliLibrary   2.0.3
#Library            SikuliLibrary     mode=NEW   **--- this option also can't work**
#Suite Setup        Start Sikuli Process
Library        Remote        http://127.0.0.1:53126/
Suite Teardown     Remote.Stop Remote Server

*** Test Cases ***
New Mode
    Add Image Path     /robot_img
    click    google_icon.png

java -jar SikuliLibrary.jar 53126

WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance. 11:12:29.232 [main] INFO org.eclipse.jetty.util.log - Logging initialized @526ms to org.robotframework.remoteserver.logging.Jetty2Log4J 11:12:29.304 [main] INFO org.eclipse.jetty.server.Server - jetty-9.4.31.v20200723; built: 2020-07-23T17:57:36.812Z; git: 450ba27947e13e66baa8cd1ce7e85a4461cacc1d; jvm 11.0.22+7-post-Ubuntu-0ubuntu223.10.1 11:12:29.367 [main] INFO org.eclipse.jetty.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@8458f04{/,null,AVAILABLE} 11:12:29.402 [main] INFO org.eclipse.jetty.server.AbstractConnector - Started ServerConnector@561b6512{HTTP/1.1, (http/1.1)}{0.0.0.0:53126} 11:12:29.402 [main] INFO org.eclipse.jetty.server.Server - Started @696ms Opening in existing browser session. Exception in thread "Thread-8" java.lang.ExceptionInInitializerError at java.prefs/java.util.prefs.FileSystemPreferencesFactory.userRoot(FileSystemPreferencesFactory.java:41) at java.prefs/java.util.prefs.Preferences.userRoot(Preferences.java:457) at java.prefs/java.util.prefs.Preferences.userNodeForPackage(Preferences.java:371) at org.sikuli.basics.PreferencesUser.(PreferencesUser.java:53) at org.sikuli.basics.PreferencesUser.get(PreferencesUser.java:57) at org.sikuli.script.support.RunTime.cleanUp(RunTime.java:1350) at org.sikuli.script.support.RunTime.runShutdownHook(RunTime.java:1364) at org.sikuli.script.support.RunTime.access$000(RunTime.java:42) at org.sikuli.script.support.RunTime$3.run(RunTime.java:1056) Caused by: java.lang.IllegalStateException: Shutdown in progress at java.base/java.lang.ApplicationShutdownHooks.add(ApplicationShutdownHooks.java:66) at java.base/java.lang.Runtime.addShutdownHook(Runtime.java:216) at java.prefs/java.util.prefs.FileSystemPreferences$4.run(FileSystemPreferences.java:457) at java.prefs/java.util.prefs.FileSystemPreferences$4.run(FileSystemPreferences.java:455) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.prefs/java.util.prefs.FileSystemPreferences.(FileSystemPreferences.java:455) ... 9 more

rainmanwy commented 6 months ago
  1. did you attach all exception stack here?
  2. Ubuntu desktop or sever version?
  3. Did you execute "java -jar" in shell mode, and without "DISPLAY" environment variable?
JerryXinhui commented 6 months ago

@rainmanwy

  1. yes, I attached all the log showed in my screen.
  2. My ubantu is a desktop mode
  3. I execute this CMD by open a terminal: java -jar SikuliLibrary.jar 53126 without setting "Display" variable.
JerryXinhui commented 6 months ago

image image

rainmanwy commented 6 months ago

@rainmanwy

  1. yes, I attached all the log showed in my screen.
  2. My ubantu is a desktop mode
  3. I execute this CMD by open a terminal: java -jar SikuliLibrary.jar 53126 without setting "Display" variable.

Could you execute "echo $DISPLAY" before "java -jar SikuliLibrary.jar 53126", remember in same terminal.

rainmanwy commented 6 months ago

there is similar issue: sikuli 304 It may related sikulix. from the issue, sikuliapi 2.0.3 should be ok.

JerryXinhui commented 4 months ago

通过这种方法解决了:(来源于github的linux安装) 安装opencv

  1. sudo apt-get install libopencv4.5-java 安装linux版本的robotframework-SikuliLibrary
  2. pip install robotframework-SikuliLibrary
  3. sudo apt install maven
  4. git clone https://github.com/rainmanwy/robotframework-SikuliLibrary.git
  5. cd clone目录,在pom.xml 目录下执行 mvn compile
  6. mvn package 此时会在目录下生成一个target. 把target目录下的 SikuliLibrary.jar 拷贝到robotframework-SikuliLibrary 安装的lib目录下,原来的jar文件删除掉。比如我的是放在:/home/test/anaconda3/envs/TBR/lib/python3.9/site-packages/SikuliLibrary/lib

再运行就正常了