Closed BenjaminJamesNexia closed 4 years ago
I guess your problem is that SikuliX thinks it's in headless mode when executed from a Spring Boot application. Hence it doesn't initialize the screens.
You can set the java.awt.headless property to false.
Either from code using System.setProperty("java.awt.headless", "false")
or (preferably) by a VM argument upon application start -Djava.awt.headless=false
.
If this solution doesn't work for you it would be nice if you could provide a full stacktrace.
Awesome, thanks very much, adding this to the POM.xml file fixed the problem:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<jvmArguments>
-Xms8g
-Xmx16g
-Djava.awt.headless=false
</jvmArguments>
</configuration>
</plugin>
Glad to help.
Another option would be to change your Application class from
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
to
public class Application {
public static void main(String[] args) {
SpringApplicationBuilder builder = new SpringApplicationBuilder(Application.class);
builder.headless(false);
builder.run(args);
}
}
I am trying to use SikuliiX1 from a Spring boot application, maven
It runs fine if I test just the operation of the sikulli (ie with a main method in the class so it just runs the sikuli code), but when I run the same code within the Spring application (calling the same methods but within the Spring application) they fail with a null exception. This comes from (when I run the debugs through) a failed attempt to create new RepeatableFind. I recall seeing RaiMan comment on this being due to some reason in another post but wondering if this is something I can fix as it would be great to use Sikuli directly rather than via calling a separate jar file through a process.....
The previous comment I referred to:
RaiMan commented on this issue 2 years ago.
Apparently, the class-reference-imagePath does not work in a spring application.ImagePath.add(new ClassPathResource("images").getURL()); Is ClassPathResource Spring specific or Java standard?
https://www.bountysource.com/issues/48224460-how-to-set-imagepath-in-a-spring-boot-application-jar-package