Pivot
  1. Pivot
  2. PIVOT-780

Can't use BXMLSerializer from non-AWT threads makes background resource loading impossible

    Details

      Description

      Calling bxmlSerializer.readObject from a non-AWT thread causes the following exception:

      An error occurred at line number 5 in file /C:/Users/Piotr/Projekty/viungo/viungo-editor/target/scala_2.9.0/classes/com/viungo/editor/CircuitEditor.bxml:
      org.apache.pivot.serialization.SerializationException: java.lang.IllegalStateException: this method can only be called from the AWT event dispatch thread
      at org.apache.pivot.beans.BXMLSerializer.processStartElement(BXMLSerializer.java:769)
      at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:441)
      at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:624)
      at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:579)
      at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:540)
      at com.viungo.editor.CircuitEditor$$anon$1.execute(CircuitEditor.scala:21)
      at com.viungo.editor.CircuitEditor$$anon$1.execute(CircuitEditor.scala:18)
      at org.apache.pivot.util.concurrent.Task$ExecuteCallback.run(Task.java:42)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
      at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      at java.lang.Thread.run(Thread.java:662)
      Caused by: java.lang.IllegalStateException: this method can only be called from the AWT event dispatch thread
      at org.apache.pivot.wtk.Container$1.run(Container.java:864)
      at org.apache.pivot.wtk.Container.assertEventDispatchThread(Container.java:871)
      at org.apache.pivot.wtk.WTKListenerList.add(WTKListenerList.java:36)
      at org.apache.pivot.wtk.skin.ComponentSkin.install(ComponentSkin.java:96)
      at org.apache.pivot.wtk.skin.ContainerSkin.install(ContainerSkin.java:129)
      at org.apache.pivot.wtk.skin.WindowSkin.install(WindowSkin.java:66)
      at org.apache.pivot.wtk.Component.setSkin(Component.java:749)
      at org.apache.pivot.wtk.Component.installSkin(Component.java:812)
      at org.apache.pivot.wtk.Window.<init>(Window.java:453)
      at org.apache.pivot.wtk.Window.<init>(Window.java:448)
      at com.viungo.editor.EditorWindow.<init>(EditorWindow.scala:20)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      at java.lang.Class.newInstance0(Class.java:355)
      at java.lang.Class.newInstance(Class.java:308)
      at org.apache.pivot.beans.BXMLSerializer.newTypedObject(BXMLSerializer.java:1556)
      at org.apache.pivot.beans.BXMLSerializer.processStartElement(BXMLSerializer.java:767)
      ... 11 more

      Loading objects in background is very important, so that the user can see e.g. a progress indicator while the rest of the UI is deserialized.
      Doing this in AWT thread, blocks what is currently displayed.

        Issue Links

          Activity

          No work has yet been logged on this issue.

            People

            • Assignee:
              Noel Grandin
              Reporter:
              Piotr Kołaczkowski
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development