start up problem: jna.platform.win32.Psapi - NoSuchMethodError

Asked by Sahil Doshi

While creating Pattern from URI of png Image file

URI uri = Test.class.getResource("1.png");
Pattern pattern = new Pattern(uri);

getting following error.
Exception in thread "main" java.lang.NoSuchMethodError: com.sun.jna.platform.win32.Psapi$MODULEINFO.createFieldsOrder([Ljava/lang/String;)Ljava/util/List;
 at com.sun.jna.platform.win32.Psapi$MODULEINFO.<clinit>(Psapi.java:269)
 at java.lang.Class.forName0(Native Method)
 at java.lang.Class.forName(Class.java:264)
 at com.sun.proxy.$Proxy3.<clinit>(Unknown Source)
...
 at com.sun.jna.platform.win32.Psapi.<clinit>(Psapi.java:47)
 at org.sikuli.natives.WinUtil.<clinit>(WinUtil.java:39)
 at org.sikuli.script.support.RunTime.addToWindowsSystemPath(RunTime.java:1718)
 at org.sikuli.script.support.RunTime.libsExport(RunTime.java:1661)
 at org.sikuli.script.support.RunTime.libsLoad(RunTime.java:1486)
 at org.sikuli.script.support.RunTime.loadLibrary(RunTime.java:1690)
 at org.sikuli.script.Finder$Finder2.<clinit>(Finder.java:571)
...

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#2

Has nothing to do with the usage of SikuliX features.

It is a system setup problem.
It happens, when SikuliX tries to register the path to the exported libs in the registry using JNA.

What system exactly?
What Java version?
What SikuliX version?

you can run this:
java -jar <path-to>/sikulix.jar -v

to get detailed startup information

Revision history for this message
Sahil Doshi (sahil13) said :
#3

System: Windows 10
Java: 1.8.0_161
SikuliApi: Build 270

Revision history for this message
RaiMan (raimund-hocke) said :
#4

when running SikuliX:
do you have another com.sun.jna package on your classpath?

BTW: no problems on my Windows 10 with the actual sikulix.jar

Revision history for this message
Sahil Doshi (sahil13) said :
#5

Yes, I have another com.sun.jna which belong to selenium jar

Revision history for this message
Best RaiMan (raimund-hocke) said :
#6

ok, then both cannot be used together this way.

the jna package in SikuliX is of version 4.5.2 and it is the successor net.java.dev.jna.
You have to check, wether this works with selenium too and then change your setup.

Revision history for this message
Sahil Doshi (sahil13) said :
#7

Thanks RaiMan, that solved my question.

Revision history for this message
Lukáš Loucký (dertdrill) said :
#8

Hi. I got the same problem. I use Selenium and Sikulix in the same project. Everything works fine for SikuliX 1.1.3 but with 1.1.4 I got the problem with com.sun.jna
It's really issue for me. Is there some solution what can I do to use both of them? 1.1.4 is important for me because of better OCR.
Thank you.

Revision history for this message
Sahil Doshi (sahil13) said :
#9

One option is you can update selenium.

Revision history for this message
Lukáš Loucký (dertdrill) said :
#10

I use selenium-java 3.141.59 It should be the latest stable version

Revision history for this message
RaiMan (raimund-hocke) said :
#11

Please try the latest build/snapshot from yesterday.

Revision history for this message
Lukáš Loucký (dertdrill) said :
#12

I will try it at Thursday (lot of projects and work) and will let you know here. Thank you.

Revision history for this message
Lukáš Loucký (dertdrill) said :
#13

Well I tried latest build 1.1.4-20190618.120945-196 + with newer jna version. Error with jna is gone but now I got this:

java.lang.ExceptionInInitializerError
 at org.sikuli.script.Finder$FindInput2.<clinit>(Finder.java:1210)
 at org.sikuli.script.Finder.<init>(Finder.java:36)
 at org.sikuli.script.Region.doCheckLastSeenAndCreateFinder(Region.java:3007)
.....
Caused by: org.sikuli.script.SikuliXception: fatal: loadlib: opencv_java320.dll not in any libs folder

Revision history for this message
Lukáš Loucký (dertdrill) said :
#14

After all I finally fixed the problem in some was.
Running Sikulix 1.1.4-SNAPSHOT from maven dependency still not works. But import of sikulixapi.jar into project works with small edit. Looks like there are conflicts between Sikulix 1.1.4 and Selenium in com.google.common (I think it's Guava libraries). So I deleted this from sikulixapi.jar and it's working now. For both, Sikulix 1.1.4 and Selenium.