← Back to team overview

sikuli-driver team mailing list archive

[Question #142062]: [Java] Apache Ant: ExceptionInInitializerError using Sikuli --- global path settings not recognized

 

Question #142062 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/142062

Description changed to:
*** the solution ***
I use Apache Ant to build and run the tests. It turned out that even though the PATH is correctly set on the shell running the ant command, AN does not pass it correctly. Therefore I had to modify the ant target to manually set it.

<exec executable="java">
   <arg line="-cp ${sikuli.classpath} com.hmh.qa.test.TestCycleTest"/>
   <env key="Path" path="${env.Path}${path.separator}${jre.bin}${path.separator}${sikuli.dir}/lib"/>
</exec>
-------------------------------------------------------

I'm trying to run some simple Sikuli code through java, and I get an
exception when Sikuli is being initialized. The following is logged.

Windows utilities loaded.
Sikuli vision engine loaded.
Text Recgonizer inited.

Then I get the stack trace below.

        N/A

java.lang.ExceptionInInitializerError
at org.sikuli.script.Finder.(Finder.java:22)
at org.sikuli.script.Region.findNow(Region.java:589)
at org.sikuli.script.Region.wait(Region.java:277)
at org.sikuli.script.Region.find(Region.java:235)
at org.sikuli.script.Region.getLocationFromPSRML(Region.java:652)
at org.sikuli.script.Region.click(Region.java:346)
at com.hmh.qa.test.TestCycleTest.takeAssessment(TestCycleTest.java:97)
at com.hmh.qa.test.TestCycleTest.testStudentTakesTest(TestCycleTest.java:85)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NullPointerException
at java.io.Reader.(Reader.java:61)
at java.io.InputStreamReader.(InputStreamReader.java:55)
at org.sikuli.script.ResourceExtractor.writeFileList(ResourceExtractor.java:23)
at org.sikuli.script.ResourceExtractor.extract(ResourceExtractor.java:17)
at org.sikuli.script.TextRecognizer.init(TextRecognizer.java:30)
at org.sikuli.script.TextRecognizer.(TextRecognizer.java:24)
at org.sikuli.script.TextRecognizer.getInstance(TextRecognizer.java:45)
at org.sikuli.script.TextRecognizer.(TextRecognizer.java:16)

The code triggering the exception is given below. Line 97 that generates
the exception is the screen.click() statement

		Screen screen = new Screen();
		screen.click("etc/imgs/English.png", 0);

I have done all the pre-requisites as suggested.

1. sikuli-script.jar is in the classpath
2. C:\Program Files\Java\jre6\bin;C:\Program Files\Sikuli X\libs are in the path

I have a python script of the same code. It runs from the command line
with the following command.

java -jar target\lib\sikuli-script.jar sikuli.sikuli

The environment details are given below
OS: Win XP (SP3)
Java: 6
Sikuli: Sikuli-X-1.0rc1-win32.exe

Please help me resolve the issue. I need the code to run from Java since
it is within a test case already automated using Selenium RC.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.