Question

I am trying to access a web page from CodeNameOne application. Strangely the simulator is throwing errors whereas the application is working fine in andriod mobile.

Code Snippet:

Form loginForm = new Form("LoginNew"); loginForm.setLayout(new BorderLayout()); WebBrowser browser = new WebBrowser() browser.setURL("http://mobile.apps-tek.com:8081/apps-webservices"); loginForm.addComponent(BorderLayout.CENTER,browser); loginForm.show();

Error while running in simulator.

Attribute 'xmlns' is not supported for tag 'html'.
The tag 'script' is not supported in XHTML-MP 1.0
The tag 'script' is not supported in XHTML-MP 1.0
Attribute 'onload' is not supported for tag 'body'.
Attribute 'name' is not supported for tag 'form'.
The tag 'script' is not supported in XHTML-MP 1.0
The tag 'script' is not supported in XHTML-MP 1.0
The tag 'script' is not supported in XHTML-MP 1.0
Attribute 'onclick' is not supported for tag 'input'.
The tag 'script' is not supported in XHTML-MP 1.0
java.lang.NullPointerException
    at com.codename1.impl.javase.JavaSEPort.scale(JavaSEPort.java:3047)
    at com.codename1.ui.Image.scale(Image.java:930)
    at com.codename1.ui.Image.scaled(Image.java:900)
    at com.codename1.ui.html.ResourceThreadQueue$ResourceThread.handleImage(ResourceThreadQueue.java:562)
    at com.codename1.ui.html.ResourceThreadQueue$ResourceThread.handleImage(ResourceThreadQueue.java:511)
    at com.codename1.ui.html.ResourceThreadQueue$ResourceThread.access$000(ResourceThreadQueue.java:360)
    at com.codename1.ui.html.ResourceThreadQueue$ResourceThread$1.run(ResourceThreadQueue.java:479)
    at com.codename1.ui.Display.processSerialCalls(Display.java:1075)
    at com.codename1.ui.Display.edtLoopImpl(Display.java:1019)
    at com.codename1.ui.Display.mainEDTLoop(Display.java:925)
    at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
    at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)
[EDT] 0:0:0,0 - Exception in AppName version 1.0
[EDT] 0:0:0,1 - OS ios
[EDT] 0:0:0,1 - Error java.lang.NullPointerException
[EDT] 0:0:0,1 - Current Form null
[EDT] 0:0:0,1 - Exception: java.lang.NullPointerException - null
java.lang.NullPointerException
    at com.codename1.impl.javase.JavaSEPort.scale(JavaSEPort.java:3047)
    at com.codename1.ui.Image.scale(Image.java:930)
    at com.codename1.ui.Image.scaled(Image.java:900)
    at com.codename1.ui.html.ResourceThreadQueue$ResourceThread.handleImage(ResourceThreadQueue.java:562)
    at com.codename1.ui.html.ResourceThreadQueue$ResourceThread.handleImage(ResourceThreadQueue.java:511)
    at com.codename1.ui.html.ResourceThreadQueue$ResourceThread.access$000(ResourceThreadQueue.java:360)
    at com.codename1.ui.html.ResourceThreadQueue$ResourceThread$1.run(ResourceThreadQueue.java:479)
    at com.codename1.ui.Display.processSerialCalls(Display.java:1075)
    at com.codename1.ui.Display.edtLoopImpl(Display.java:1019)
    at com.codename1.ui.Display.mainEDTLoop(Display.java:925)
    at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
    at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)
Was it helpful?

Solution

It seems you are using Java 6 or Java 7 that is configured without Java FX support. When running without Java FX Codename One defaults to the feature phone web browser component which is pretty limited and problematic.

Make sure that the VM used to run Codename One is Java SE 7 and that the additional Java FX libraries are included there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top