[1.1.1] new VNCScreen(): crashes with NPE

Asked by sayantan

I am able to connect to the vnc socket, but after that the execution of
VNCScreen vnc = new VNCScreen() gives error :

Exception in thread "main" java.lang .ExceptionInInitializationError
 at run.main(run.java.27)
Caused by :java.lang.NullPointException
 at edu.unh.iol.dlc.VNCScreen.initScreens(VNCScreen.java:102) ----> is this error being caused due to some bugs in the Sikulix.jar package
 at edu.unh.iol.dlc.VNCScreen.<clinit>(VNCScreen.java:67)

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
sayantan (sayantan-bhowmik94) said :
#1

I am able to open up a VNC connection, but setting up VNCScreen gives an error !

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

please post the complete initialization code

Revision history for this message
sayantan (sayantan-bhowmik94) said :
#3

import edu.unh.iol.dlc.*
public static.........
{
Socket s=new Socket("127.0.0.1",5929)
s.setSoTimeout(1000)
ConnectionController cc =new ConnectionController(s)
cc.openConnection(0);
cc.start(0);
--------------------------------------------------------------------------------------
<Until this point code runs fine ,but after this line >
VNCScreen vnc= new VNCScreen() , generates an error

>Exception in thread "main" java.lang .ExceptionInInitializationError
 at run.main(run.java.27)
Caused by :java.lang.NullPointException
 at edu.unh.iol.dlc.VNCScreen.initScreens(VNCScreen.java:102)
 at edu.unh.iol.dlc.VNCScreen.<clinit>(VNCScreen.java:67)

So,is this caused by some issues in the VNCScreen.java file ?

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

thanks.

--- So,is this caused by some issues in the VNCScreen.java file ?

... yes, I think the VNCScreen() constructor had a problem and I think I fixed it now.

please try this instead for now:
VNCScreen vnc= new VNCScreen(0);

... and when the fix is online later, I would appreciate if you try again with:
VNCScreen vnc= new VNCScreen();

Revision history for this message
sayantan (sayantan-bhowmik94) said :
#5

i tried using VNCScreen vnc= new VNCScreen(0); , but this doesn't work

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

outcome?

run with -d 4 and post the log

Revision history for this message
sayantan (sayantan-bhowmik94) said :
#7

Connected[info] runcmd: lsb_release -i -r -s
Exception in thread "main" java.lang.ExceptionInInitializerError
    at run.main(run.java:28)
Caused by: java.lang.NullPointerException
    at edu.unh.iol.dlc.VNCScreen.initScreens(VNCScreen.java:102)
    at edu.unh.iol.dlc.VNCScreen.<clinit>(VNCScreen.java:67)
    ... 1 more

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

what about the log?

Revision history for this message
sayantan (sayantan-bhowmik94) said :
#9

i haven't set the log label yet , i was running it on Eclipse

Revision history for this message
sayantan (sayantan-bhowmik94) said :
#10

i did try to run VNCScreen vnc = new VNCScreen() with the new fix available , and this is what i get :

[error] VNCScreen: initScreens: 0 has no connection yet
Exception in thread "main" java.lang.UnsupportedOperationException: initScreens: none of the remote screens has a valid connection
    at edu.unh.iol.dlc.VNCScreen.initScreens(VNCScreen.java:222)
    at edu.unh.iol.dlc.VNCScreen.<init>(VNCScreen.java:140)
    at run.main(run.java:30)

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

you have to wait:
the solution including some doc comments will be available with the next nightly build.

Revision history for this message
sayantan (sayantan-bhowmik94) said :
#12

ok, thank you can you plz tell me, by when it would be available ?

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

on github later this day, the nightly tomorrow.

Revision history for this message
sayantan (sayantan-bhowmik94) said :
#14

OK thanks !

Revision history for this message
sayantan (sayantan-bhowmik94) said :
#15

I want to ask you about a different issue , just need your suggestion on that :

I am trying to package Sikuli as an rpm so I can distribute and deploy it in other systems.

Currently, I am facing difficulties, as the RPM cannot launch the UI that is popped up in Sikuli’s manual install.

Is there a silent installer for Sikuli and its dependencies?

If there isn’t, I can help create it – but will need pointers about what needs to be done.

Can you please let me know?

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

--- silent setup:
faq 2609

--- VNC state
this is now available with the latest nightly build:

--- Python scripts:
vnc = vncStart("192.168.2.24")

tries a connection to a VNC server on the given IP using port 5900

the method doc:
## -----------------------------------------------------------------------
# vncStart(ip="127.0.0.1", port=5900, connectionTimeout=10, timeout=1000):
# convenience for a VNCScreen connection
# ip the server IP (default: 127.0.0.1)
# port the port number (default 5900)
# connectionTimeout seconds to wait for a valid connection (default 10)
# timeout the timout value in milli-seconds during normal operation (default 1000)
# returns a VNCScreen object
# use theVNCScreen.stop() to stop this connection again (auto-stopped at script end)

--- in Java
VNCScreen vnc = VNCScreen.start(theIP, thePort, cTimeout, timeout);

all parameters must be given, no defaults

on success, vnc can be used like a Screen object.

to stop a session:
vnc.stop()

this is tested from Mac to a TightVNC server on Windows

principally possible, but not yet tested: you can have more than one session (VNCScreens) in parallel

I will add more information in the docs:
http://sikulix-2014.readthedocs.io/en/latest/screen.html#connecting-to-a-vnc-server-vncscreen

Revision history for this message
sayantan (sayantan-bhowmik94) said :
#17

Btw sir, i am still facing problem while running VNCScreen vnc=new VNCScreen() .

Revision history for this message
sayantan (sayantan-bhowmik94) said :
#18

OK thank you for the information :)

Revision history for this message
sayantan (sayantan-bhowmik94) said :
#19

I am running on RHEL and trying to connect to Tiger VNC :

VNCScreen vnc = VNCScreen.start("127.0.0.1",5903,10,1000)

Error:
[error] VNCScreen: initScreens: 0 has no connection yet
[error] VNCScreen: initScreens: 1 has no connection yet
Exception in thread "main" java.lang.UnsupportedOperationException: initScreens: none of the remote screens has a valid connection
    at edu.unh.iol.dlc.VNCScreen.initScreens(VNCScreen.java:235)
    at edu.unh.iol.dlc.VNCScreen.<init>(VNCScreen.java:153)
    at edu.unh.iol.dlc.VNCScreen.start(VNCScreen.java:98)
    at test.main(test.java:26)

Revision history for this message
sayantan (sayantan-bhowmik94) said :
#20

can you please tell me about the java version you are running on . Are their any dependencies with java version ?

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

for me everything works as expected.

Since I do not know, how exactly you are running your Java stuff:
put a
Debug.on(4)

just before the
VNCScreen vnc = VNCScreen.start("127.0.0.1",5903,10,1000)

to get more debug info.

I am usually running Oracle Java 8 latest build.

sure you are using the build from to night (2016-05-27_01:01nightly)?

Revision history for this message
sayantan (sayantan-bhowmik94) said :
#22

yes i am using the build from to night (2016-05-27_01:01nightly

Connected[debug] Debug.init: from sikuli.Debug: on: 4
*** system properties dump
awt.toolkit = sun.awt.X11.XToolkit
file.encoding = UTF-8
file.encoding.pkg = sun.io
file.separator = /
java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment
java.awt.printerjob = sun.print.PSPrinterJob
java.class.path = /home/bhowmik/workspace1/test_run/bin:/home/bhowmik/.Sikulix/SikulixSetup/sikulix.jar
java.class.version = 51.0
java.endorsed.dirs = /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.85.x86_64/jre/lib/endorsed
java.ext.dirs = /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.85.x86_64/jre/lib/ext:/usr/java/packages/lib/ext
java.home = /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.85.x86_64/jre
java.io.tmpdir = /tmp
java.library.path = /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
java.runtime.name = OpenJDK Runtime Environment
java.runtime.version = 1.7.0_85-mockbuild_2015_07_13_05_49-b00
java.specification.name = Java Platform API Specification
java.specification.vendor = Oracle Corporation
java.specification.version = 1.7
java.vendor = Oracle Corporation
java.vendor.url = http://java.oracle.com/
java.vendor.url.bug = http://bugreport.sun.com/bugreport/
java.version = 1.7.0_85
java.vm.info = mixed mode
java.vm.name = OpenJDK 64-Bit Server VM
java.vm.specification.name = Java Virtual Machine Specification
java.vm.specification.vendor = Oracle Corporation
java.vm.specification.version = 1.7
java.vm.vendor = Oracle Corporation
java.vm.version = 24.85-b03
line.separator =

os.arch = amd64
os.name = Linux
os.version = 2.6.32-573.3.1.el6.x86_64
path.separator = :
sun.arch.data.model = 64
sun.boot.class.path = /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.85.x86_64/jre/lib/resources.jar:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.85.x86_64/jre/lib/rt.jar:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.85.x86_64/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.85.x86_64/jre/lib/jsse.jar:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.85.x86_64/jre/lib/jce.jar:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.85.x86_64/jre/lib/charsets.jar:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.85.x86_64/jre/lib/rhino.jar:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.85.x86_64/jre/lib/jfr.jar:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.85.x86_64/jre/classes
sun.boot.library.path = /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.85.x86_64/jre/lib/amd64
sun.cpu.endian = little
sun.cpu.isalist =
sun.desktop = gnome
sun.io.unicode.encoding = UnicodeLittle
sun.java.command = test
sun.java.launcher = SUN_STANDARD
sun.jnu.encoding = UTF-8
sun.management.compiler = HotSpot 64-Bit Tiered Compilers
sun.os.patch.level = unknown
user.country = US
user.dir = /home/bhowmik/workspace1/test_run
user.home = /home/bhowmik
user.language = en
user.name = bhowmik
user.timezone = Asia/Kolkata
*** system properties dump end
[debug] RunTimeINIT: lsb_release -i -r -s
[debug] RunTimeINIT: loadOptions: check: /home/bhowmik/workspace1/test_run
[debug] RunTimeINIT: loadOptions: check: /home/bhowmik
[debug] RunTimeINIT: loadOptions: check: /home/bhowmik/.Sikulix/SikulixStore
[error] Settings: load version file sikulixversion.txt did not work
[debug] Sikulix: endError: 999
[debug] Sikulix: cleanUp: 999
Exception in thread "main" java.lang.ExceptionInInitializerError
    at test.main(test.java:29)
Caused by: java.lang.NullPointerException
    at java.util.ArrayList.addAll(ArrayList.java:559)
    at edu.unh.iol.dlc.VNCScreen.cleanUp(VNCScreen.java:129)
    at org.sikuli.script.Sikulix.cleanUp(Sikulix.java:448)
    at org.sikuli.script.Sikulix.endError(Sikulix.java:405)
    at org.sikuli.script.RunTime.initSikulixOptions(RunTime.java:1630)
    at org.sikuli.script.RunTime.get(RunTime.java:288)
    at org.sikuli.script.RunTime.get(RunTime.java:121)
    at org.sikuli.script.RunTime.get(RunTime.java:315)
    at org.sikuli.script.Region.<clinit>(Region.java:31)
    ... 1 more

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

... and what if you run simply this:

Screen s = new Screen();
Debug.on(3)
VNCScreen vnc = VNCScreen.start("127.0.0.1",5903,10,1000)

... seems, that using Debug as the first Sikulix class makes a problem.

could you please tell me a bit more details about how you are running your java stuff.

Revision history for this message
sayantan (sayantan-bhowmik94) said :
#24

[info] runcmd: lsb_release -i -r -s
[debug] VNCScreen: VNCScreen: request for connection localhost:5903
[debug] java.io.EOFException
2[error] VNCScreen: initScreens: 0 has no connection yet
2[error] VNCScreen: initScreens: 1 has no connection yet
Exception in thread "main" java.lang.UnsupportedOperationException: initScreens: none of the remote screens has a valid connection
 at edu.unh.iol.dlc.VNCScreen.initScreens(VNCScreen.java:236)
 at edu.unh.iol.dlc.VNCScreen.<init>(VNCScreen.java:154)
 at edu.unh.iol.dlc.VNCScreen.start(VNCScreen.java:98)
 at test.main(test.java:30)

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

sure your TigerVNC allows loopback connections (in TightVNC you have to switch this on seperately)

Revision history for this message
sayantan (sayantan-bhowmik94) said :
#26

The java version I am using is 1.7.0_85. I am going to try with version 8 and report out what I see.

Btw, here's the java application that I've come up with. I am running into the errors above at the VNCScreen.start (commented below)

import java.io.IOException;
import java.net.Socket;

import org.sikuli.basics.Debug;
import org.sikuli.script.*;
import edu.unh.iol.dlc.ConnectionController;
import edu.unh.iol.dlc.VNCScreen;

public class test {
 public static void main(String[] args) {
  try{

   Socket s=new Socket("127.0.0.1",5903);
   //if(s.isConnected())
      // System.out.print("Connected");
     // else
      // System.out.print("Not Connected");

   //s.setSoTimeout(1000);
   //s.setKeepAlive(true);
   ConnectionController cc = new ConnectionController(s);
   cc.openConnection(0);
      cc.start(0);
   Thread.sleep(2000);
   Screen S =new Screen();
   Debug.on(3);
  //VNCScreen vnc = VNCScreen.start("127.0.0.1", 5903,10, 10000);
 // vnc.click();

  }
  catch(IOException | InterruptedException e)
  {
   System.out.print("error");
  }
 }
}

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

sorry, might not have been clear enough:

you either use the convenience VNCScreen.start() OR the detailed way with socket.

so a valid test would be:

import org.sikuli.basics.Debug;
import org.sikuli.script.*;
import edu.unh.iol.dlc.VNCScreen;

public class test {
 public static void main(String[] args) {
   Screen S =new Screen();
   Debug.on(3);
   VNCScreen vnc = VNCScreen.start("127.0.0.1", 5903,10, 10000);
   vnc.click(); // should click center of remote screen
}

Revision history for this message
sayantan (sayantan-bhowmik94) said :
#28

We have a emulator - qemu - that runs a virtual machine (linux). Qemu hosts a vncserver as a part of its process on a given port (5903 in the code above). We launch a vnc session into it using tigervnc viewer - this works well when we run it on the desktop.

I'll check if the issue exists with java 8 and report out.

Revision history for this message
sayantan (sayantan-bhowmik94) said :
#29

i did as you said, this is what i get :

debug] Debug.init: from sikuli.Debug: on: 3
[debug] RunTimeINIT: lsb_release -i -r -s
[debug] RunTimeINIT: loadOptions: check: /home/bhowmik/workspace1/TestSikuli
[debug] RunTimeINIT: loadOptions: check: /home/bhowmik
[debug] RunTimeINIT: loadOptions: check: /home/bhowmik/.Sikulix/SikulixStore
[debug] RunTimeINIT: global init: entering as: API
[debug] RunTimeINIT: ScreenDevice 0 has (0,0) --- will be primary Screen(0)
[debug] RunTimeINIT: Monitor 0: (0, 0) 1600 x 1200
[debug] RunTimeINIT: runs as sikulix.jar in: /home/bhowmik/.Sikulix/SikulixSetup
[debug] RunTimeINIT: exists libs folder at: /home/bhowmik/.Sikulix/SikulixLibs_201605271247
***** show environment for API (build 201605271247)
user.home: /home/bhowmik
user.dir (work dir): /home/bhowmik/workspace1/TestSikuli
user.name: bhowmik
java.io.tmpdir: /tmp
running 64Bit on Linux (0 RedHatEnterpriseWorkstation 6.7) from a jar
java 8-64 version 1.8.0_51-b16 vm 25.51-b03 class 52.0 arch amd64
app data folder: /home/bhowmik/.Sikulix
libs folder: /home/bhowmik/.Sikulix/SikulixLibs_201605271247
executing jar: /home/bhowmik/.Sikulix/SikulixSetup/sikulix.jar
*** classpath dump sikulix
  1: /home/bhowmik/.Sikulix/SikulixSetup/sikulix.jar
*** classpath dump end
***** show environment end
[debug] RunTimeAPI: global init: leaving
[debug] RunTimeAPI: initAPI: entering
[debug] RunTimeAPI: resourceList: enter
[debug] RunTimeAPI: resourceLocation: (class org.sikuli.script.RunTime) /Lib/sikuli
[debug] RunTimeAPI: resourceList: having jar: jar:file:/home/bhowmik/.Sikulix/SikulixSetup/sikulix.jar!/Lib/sikuli
[debug] RunTimeAPI: files exported: 7 from: Lib/sikuli to:
 /home/bhowmik/.Sikulix/Lib/sikuli
[debug] RunTimeAPI: initAPI: leaving
[debug] RunTimeAPI: loadLib: libVisionProxy.so
[debug] VNCScreen: VNCScreen: request for connection 127.0.0.1:5903
[debug] java.io.EOFException
[error] VNCScreen: initScreens: 0 has no connection yet
Error: java.lang.UnsupportedOperationException: initScreens: none of the remote screens has a valid connection

Revision history for this message
sayantan (sayantan-bhowmik94) said :
#30

Ok, i could connect to the VNC session .
But in the VNC window vnc.click() doesn't clicks with in the VNC session window.

Revision history for this message
sayantan (sayantan-bhowmik94) said :
#31

LIke , i need to manually place the mouse pointer inside the VNC window , and then i could get a click.

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

--- LIke , i need to manually place the mouse pointer inside the VNC window , and then i could get a click.
I guess this is a special problem of your special setup.
You have to find out yourself, since I do not have any chance to test that.

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

I guess the original problem is solved now.

For new issues/questions please start a new thread.

Revision history for this message
sayantan (sayantan-bhowmik94) said :
#34

yes its solved.