I'm trying to run this open-source project, rokuality-server (full codebase here: https://github.com/rokuality/rokuality-server).
But in this method below I'm getting a java.lang.NoClassDefFoundError
when trying to instantiate any Sikuli classes like Pattern
or Finder
.
import org.sikuli.script.Finder;
import org.sikuli.script.Image;
import org.sikuli.script.Match;
import org.sikuli.script.Pattern;
@SuppressWarnings("unchecked")
public class ImageUtils {
private static JSONObject getElement(String sessionID, String locator, File screenImage) {
JSONObject element = new JSONObject();
element.put(SessionConstants.ELEMENT_ID, UUID.randomUUID().toString());
boolean isFile = locator != null && new File(locator).exists();
boolean elementFound = false;
if (!screenImage.exists()) {
return null;
}
if (isFile) {
Finder finder = null;
float similarity = Float.valueOf(
SessionManager.getSessionInfo(sessionID).get(SessionConstants.IMAGE_MATCH_SIMILARITY).toString());
Pattern pattern = null;
try {
//******** THIS LINE BELOW THROWS THE ERROR ********
pattern = new Pattern(locator).similar(similarity);
finder = new Finder(screenImage.getAbsolutePath());
} catch (Exception e) {
Log.getRootLogger().warn(e);
}
}
// more code here
}
}
My suspicion is that something in the pom.xml
file is wrong, so here's the Sikuli X Api dependency as it appears there:
<dependency>
<groupId>com.sikulix</groupId>
<artifactId>sikulixapi</artifactId>
<version>1.1.2</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
</exclusion>
<exclusion>
<groupId>com.github.vidstige</groupId>
<artifactId>jadb</artifactId>
</exclusion>
<exclusion>
<groupId>com.sikulix</groupId>
<artifactId>sikulix2tigervnc</artifactId>
</exclusion>
</exclusions>
</dependency>
I tried changing the version to the latest one, 2.0.0
but it caused some errors in the project, which I think are related to changes in the org.sikuli.script.Image
class's methods. Do I maybe need an earlier version?
This should be fixed in the newer releases of the rokuality project: https://github.com/rokuality/rokuality-server/releases. It depended on the java jdk version the user was running.