Using WebView raises exception - Application thread needed

65 views
Skip to first unread message

Andreas

unread,
Sep 22, 2015, 5:25:16 PM9/22/15
to JRebirth Users
Hi Seb,

me again :). So now I implemented navigation via waves and FadeTransitionCommands. All is working fine.

But, if I try to use the WebView control of JavaFX the application crasches with exception below. Seams the loading of FXML don't happen in UI/Application thread.

I thought, it is may a failure of how I navigate and tried same in your showcase application.

I put only following into the org.jrebirth.af.showcase.fxml.ui.standalone.Standalone.fxml:

...
<VBox prefHeight="120.0" prefWidth="600.0">
          <children>
            <WebView />
            <Label prefWidth="273.0" text="%title">
...

Same exception.

Have you any idea what I can to make the WebView control can be loaded?!

Thanks a lot in advance!

Andreas
 

Exception
---------------

23:06:40.526 [JTP Slot 3] ERROR o.j.a.c.c.JRebirthThreadPoolExecutor - JTP returned an error
org.jrebirth.af.api.exception.CoreRuntimeException: The FXML node doesnt exist : {0}
    at org.jrebirth.af.core.ui.fxml.FXMLUtils.loadFXML(FXMLUtils.java:128) ~[core-8.1.0-SNAPSHOT.jar:na]
    at org.jrebirth.af.core.ui.fxml.AbstractFXMLObjectModel.initInternalModel(AbstractFXMLObjectModel.java:117) ~[core-8.1.0-SNAPSHOT.jar:na]
    at org.jrebirth.af.core.ui.AbstractBaseModel.ready(AbstractBaseModel.java:56) ~[core-8.1.0-SNAPSHOT.jar:na]
    at org.jrebirth.af.core.component.basic.AbstractComponent.setup(AbstractComponent.java:503) ~[core-8.1.0-SNAPSHOT.jar:na]
    at org.jrebirth.af.core.facade.AbstractFacade.retrieve(AbstractFacade.java:216) ~[core-8.1.0-SNAPSHOT.jar:na]
    at org.jrebirth.af.core.command.basic.showmodel.PrepareModelCommand.perform(PrepareModelCommand.java:56) ~[core-8.1.0-SNAPSHOT.jar:na]
    at org.jrebirth.af.core.command.AbstractBaseCommand.innerRun(AbstractBaseCommand.java:185) ~[core-8.1.0-SNAPSHOT.jar:na]
    at org.jrebirth.af.core.command.CommandRunnable.runInto(CommandRunnable.java:67) ~[core-8.1.0-SNAPSHOT.jar:na]
    at org.jrebirth.af.core.concurrent.AbstractJrbRunnable.run(AbstractJrbRunnable.java:80) ~[core-8.1.0-SNAPSHOT.jar:na]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_60]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_60]
    at java.lang.Thread.run(Unknown Source) [na:1.8.0_60]
Caused by: javafx.fxml.LoadException:
/C:/Users/z-ando/workspace/JRebirth/org.jrebirth.af/showcase/fxml/target/classes/org/jrebirth/af/showcase/fxml/ui/standalone/Standalone.fxml:17

    at javafx.fxml.FXMLLoader.constructLoadException(Unknown Source) ~[jfxrt.jar:na]
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source) ~[jfxrt.jar:na]
    at javafx.fxml.FXMLLoader.load(Unknown Source) ~[jfxrt.jar:na]
    at org.jrebirth.af.core.ui.fxml.FXMLUtils.loadFXML(FXMLUtils.java:124) ~[core-8.1.0-SNAPSHOT.jar:na]
    ... 11 common frames omitted
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at javafx.fxml.JavaFXBuilder$ObjectBuilder.build(Unknown Source) ~[jfxrt.jar:na]
    at javafx.fxml.FXMLLoader$ValueElement.processEndElement(Unknown Source) ~[jfxrt.jar:na]
    at javafx.fxml.FXMLLoader.processEndElement(Unknown Source) ~[jfxrt.jar:na]
    ... 14 common frames omitted
Caused by: java.lang.reflect.InvocationTargetException: null
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_60]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_60]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_60]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_60]
    at sun.reflect.misc.Trampoline.invoke(Unknown Source) ~[na:1.8.0_60]
    at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) ~[na:na]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_60]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_60]
    at sun.reflect.misc.MethodUtil.invoke(Unknown Source) ~[na:1.8.0_60]
    ... 17 common frames omitted
Caused by: java.lang.IllegalStateException: Not on FX application thread; currentThread = JTP Slot 3
    at com.sun.javafx.tk.Toolkit.checkFxUserThread(Unknown Source) ~[jfxrt.jar:na]
    at com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(Unknown Source) ~[jfxrt.jar:na]
    at javafx.scene.web.WebEngine.checkThread(Unknown Source) ~[jfxrt.jar:na]
    at javafx.scene.web.WebEngine.<init>(Unknown Source) ~[jfxrt.jar:na]
    at javafx.scene.web.WebEngine.<init>(Unknown Source) ~[jfxrt.jar:na]
    at javafx.scene.web.WebView.<init>(Unknown Source) ~[jfxrt.jar:na]
    at javafx.scene.web.WebViewBuilder.build(Unknown Source) ~[jfxrt.jar:na]
    ... 26 common frames omitted
23:06:44.362 [JTP Slot 3] ERROR o.j.a.c.e.h.AbstractJrbUncaughtExceptionHandler - Uncaught Exception: The FXML node doesnt exist : {0}
org.jrebirth.af.api.exception.CoreRuntimeException: The FXML node doesnt exist : {0}
    at org.jrebirth.af.core.ui.fxml.FXMLUtils.loadFXML(FXMLUtils.java:128) ~[core-8.1.0-SNAPSHOT.jar:na]
    at org.jrebirth.af.core.ui.fxml.AbstractFXMLObjectModel.initInternalModel(AbstractFXMLObjectModel.java:117) ~[core-8.1.0-SNAPSHOT.jar:na]
    at org.jrebirth.af.core.ui.AbstractBaseModel.ready(AbstractBaseModel.java:56) ~[core-8.1.0-SNAPSHOT.jar:na]
    at org.jrebirth.af.core.component.basic.AbstractComponent.setup(AbstractComponent.java:503) ~[core-8.1.0-SNAPSHOT.jar:na]
    at org.jrebirth.af.core.facade.AbstractFacade.retrieve(AbstractFacade.java:216) ~[core-8.1.0-SNAPSHOT.jar:na]
    at org.jrebirth.af.core.command.basic.showmodel.PrepareModelCommand.perform(PrepareModelCommand.java:56) ~[core-8.1.0-SNAPSHOT.jar:na]
    at org.jrebirth.af.core.command.AbstractBaseCommand.innerRun(AbstractBaseCommand.java:185) ~[core-8.1.0-SNAPSHOT.jar:na]
    at org.jrebirth.af.core.command.CommandRunnable.runInto(CommandRunnable.java:67) ~[core-8.1.0-SNAPSHOT.jar:na]
    at org.jrebirth.af.core.concurrent.AbstractJrbRunnable.run(AbstractJrbRunnable.java:80) ~[core-8.1.0-SNAPSHOT.jar:na]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[na:1.8.0_60]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[na:1.8.0_60]
    at java.lang.Thread.run(Unknown Source) ~[na:1.8.0_60]
Caused by: javafx.fxml.LoadException:
/C:/Users/z-ando/workspace/JRebirth/org.jrebirth.af/showcase/fxml/target/classes/org/jrebirth/af/showcase/fxml/ui/standalone/Standalone.fxml:17

    at javafx.fxml.FXMLLoader.constructLoadException(Unknown Source) ~[jfxrt.jar:na]
    at javafx.fxml.FXMLLoader.loadImpl(Unknown Source) ~[jfxrt.jar:na]
    at javafx.fxml.FXMLLoader.load(Unknown Source) ~[jfxrt.jar:na]
    at org.jrebirth.af.core.ui.fxml.FXMLUtils.loadFXML(FXMLUtils.java:124) ~[core-8.1.0-SNAPSHOT.jar:na]
    ... 11 common frames omitted
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at javafx.fxml.JavaFXBuilder$ObjectBuilder.build(Unknown Source) ~[jfxrt.jar:na]
    at javafx.fxml.FXMLLoader$ValueElement.processEndElement(Unknown Source) ~[jfxrt.jar:na]
    at javafx.fxml.FXMLLoader.processEndElement(Unknown Source) ~[jfxrt.jar:na]
    ... 14 common frames omitted
Caused by: java.lang.reflect.InvocationTargetException: null
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_60]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_60]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_60]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_60]
    at sun.reflect.misc.Trampoline.invoke(Unknown Source) ~[na:1.8.0_60]
    at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) ~[na:na]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_60]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_60]
    at sun.reflect.misc.MethodUtil.invoke(Unknown Source) ~[na:1.8.0_60]
    ... 17 common frames omitted
Caused by: java.lang.IllegalStateException: Not on FX application thread; currentThread = JTP Slot 3
    at com.sun.javafx.tk.Toolkit.checkFxUserThread(Unknown Source) ~[jfxrt.jar:na]
    at com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(Unknown Source) ~[jfxrt.jar:na]
    at javafx.scene.web.WebEngine.checkThread(Unknown Source) ~[jfxrt.jar:na]
    at javafx.scene.web.WebEngine.<init>(Unknown Source) ~[jfxrt.jar:na]
    at javafx.scene.web.WebEngine.<init>(Unknown Source) ~[jfxrt.jar:na]
    at javafx.scene.web.WebView.<init>(Unknown Source) ~[jfxrt.jar:na]
    at javafx.scene.web.WebViewBuilder.build(Unknown Source) ~[jfxrt.jar:na]
    ... 26 common frames omitted

Sebastien Bordes

unread,
Sep 23, 2015, 3:34:26 AM9/23/15
to JRebirth Users
This is a known limitation of the WebView widget !

It can be only created from JAT, whereas all other node can be created into a separated thread (JIT ot JTP)

Thus we have added a trick (#140) to force the model to be created into JAT

In your Model constructor code set the field createViewIntoJAT to true and your view will be created correctly (but into JAT so don't perform long task during creation and init to avoid ui freeze)

Seb

Andreas

unread,
Sep 23, 2015, 4:08:09 AM9/23/15
to JRebirth Users
Hi Seb,

hmm...I tried this in your demo application, but the exception remains same:

/**
 * The class <strong>StandaloneModel</strong>.
 *
 * @author Sébastien Bordes
 */
public class StandaloneModel extends DefaultFXMLModel<StandaloneModel> {

    public StandaloneModel() {
        createViewIntoJAT = true;
    }
   
Andreas

Sebastien Bordes

unread,
Sep 23, 2015, 4:22:53 AM9/23/15
to jrebirth-users
Ok you are right, I miss a detail, the StandaloneModel doesn't have a View !!

So I will patch also ViewLess Model to allow them to use WebView.

Seb

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "JRebirth Users".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse jrebirth-user...@googlegroups.com.
Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.



--

Sebastien Bordes

unread,
Sep 23, 2015, 3:19:14 PM9/23/15
to JRebirth Users
Andreas,

I've just pushed the fix on 8.x-hotfixes branch, it brings support for SimpleModel and FXMLModel.

Moreover @CreateViewIntoJAT annotation can be used on Model class instead of overriding constructor to update the protected field

Seb
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse jrebirth-users+unsubscribe@googlegroups.com.

Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages