B4J Question results displayed only in debug mode

micro

Well-Known Member
Licensed User
Longtime User
Hi to all
i have a problem but olny in release mode, same textfield are not written and
if i remember correctly first version of b4j without internal designers worked well.
Anyway...
This segment code is inside in a class module
B4X:
Sub Handle(req As ServletRequest, resp As ServletResponse)
   Dim lock As Boolean = False
   Dim read, mbadge As Map
   read.Initialize
   read = ReadObject(req.InputStream)
   Dim operatore As String = read.Get("operatore")
      mbadge.Initialize
      mbadge = DBUtils.ExecuteMap(Main.SQL1, "SELECT * FROM Badge WHERE N_Badge = " & QUOTE & operatore & QUOTE, Null)
       If mbadge.IsInitialized = True Then
           operatore = mbadge.Get("operatore")
       Else
         operatore = "??"
       End If
      If Main.lstip1.IndexOf(ip) > -1 Then
           Dim i As Int = Main.lstip1.IndexOf(ip)
           Select Case i
                Case 0
                      ...............
                      ...............
                      Main.lboperatore1_1.Text = operatore
                      Dim l As List
                      l.Initialize
                      l = DBUtils.ExecuteMemoryTable(Main.SQL1, "SELECT * FROM " & Main.Archiviogiornaliero & "_Linea1" & " WHERE Operatore = " & QUOTE & op & QUOTE & " And Data = " & QUOTE & Main.data & QUOTE, Null, 0)
                      Main.nconflb1_1.Text = l.Size 'MAIN.NCONFLB1 NOT UPDATE IN RELEASE MODE ALSO IF L.SIZE IS CORRECT

Log in Debug mode:
B4X:
Program started.
CreateTable: CREATE TABLE IF NOT EXISTS [Badge] ([Id] INTEGER PRIMARY KEY, [N_Badge] TEXT, [Operatore] TEXT)
ExecuteMap: SELECT * FROM Badge
2015-08-21 08:10:47.361:INFO::JavaFX Application Thread: Logging initialized @10153ms
2015-08-21 08:10:47.440:INFO:oejs.Server:JavaFX Application Thread: jetty-9.1.z-SNAPSHOT
2015-08-21 08:10:47.461:WARN:oejh.MimeTypes:JavaFX Application Thread: java.util.MissingResourceException: Can't find bundle for base name org/eclipse/jetty/http/encoding, locale it_IT
2015-08-21 08:10:47.467:INFO:oejsh.ContextHandler:JavaFX Application Thread: Started o.e.j.s.ServletContextHandler@5dc234a3{/,file:/C:/Users/Me/Desktop/Pc/Objects/www,AVAILABLE}
2015-08-21 08:10:47.471:INFO:oejs.AbstractNCSARequestLog:JavaFX Application Thread: Opened C:\Users\Me\Desktop\Pc\Objects\logs\b4j-2015_08_21.request.log
2015-08-21 08:10:47.519:INFO:oejs.ServerConnector:JavaFX Application Thread: Started ServerConnector@4dbf7b6e{HTTP/1.1}{0.0.0.0:6000}
2015-08-21 08:10:47.520:INFO:oejs.Server:JavaFX Application Thread: Started @10324ms
Emulated network latency: 100ms
ExecuteMap: SELECT * FROM Badge WHERE N_Badge = "3149629"
ExecuteMemoryTable: SELECT * FROM Pesate_21_08_2015_Linea1 WHERE Operatore = "Antonio Diomede" And Data = "21/08/2015"
ExecuteMap: SELECT * FROM Badge WHERE N_Badge = "3149629"
ExecuteMemoryTable: SELECT * FROM Mov_21_08_2015_Linea1 WHERE Operatore = "Antonio Diomede" And Data = "21/08/2015"
.................................

Log in Release mode:
B4X:
Program started.
CreateTable: CREATE TABLE IF NOT EXISTS [Badge] ([Id] INTEGER PRIMARY KEY, [N_Badge] TEXT, [Operatore] TEXT)
ExecuteMap: SELECT * FROM Badge
2015-08-21 08:18:30.358:INFO::JavaFX Application Thread: Logging initialized @9133ms
2015-08-21 08:18:30.468:INFO:oejs.Server:JavaFX Application Thread: jetty-9.1.z-SNAPSHOT
2015-08-21 08:18:30.487:WARN:oejh.MimeTypes:JavaFX Application Thread: java.util.MissingResourceException: Can't find bundle for base name org/eclipse/jetty/http/encoding, locale it_IT
2015-08-21 08:18:30.493:INFO:oejsh.ContextHandler:JavaFX Application Thread: Started o.e.j.s.ServletContextHandler@6cfc1cbf{/,file:/C:/Users/Me/Desktop/Pc/Objects/www,AVAILABLE}
2015-08-21 08:18:30.497:INFO:oejs.AbstractNCSARequestLog:JavaFX Application Thread: Opened C:\Users\Me\Desktop\Pc\Objects\logs\b4j-2015_08_21.request.log
2015-08-21 08:18:30.546:INFO:oejs.ServerConnector:JavaFX Application Thread: Started ServerConnector@353d696{HTTP/1.1}{0.0.0.0:6000}
2015-08-21 08:18:30.546:INFO:oejs.Server:JavaFX Application Thread: Started @9327ms
ExecuteMap: SELECT * FROM Badge WHERE N_Badge = ""
ExecuteMap: SELECT * FROM Badge WHERE N_Badge = "3149629"
connbilhandler1._handle (java line: 179)
java.lang.IllegalStateException: Not on FX application thread; currentThread = qtp1833746706-35
    at com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:204)
    at com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:438)
    at javafx.scene.Parent$2.onProposedChange(Parent.java:364)
    at com.sun.javafx.collections.VetoableListDecorator.setAll(VetoableListDecorator.java:113)
    at com.sun.javafx.collections.VetoableListDecorator.setAll(VetoableListDecorator.java:108)
    at com.sun.javafx.scene.control.skin.LabeledSkinBase.updateChildren(LabeledSkinBase.java:575)
    at com.sun.javafx.scene.control.skin.LabeledSkinBase.handleControlPropertyChanged(LabeledSkinBase.java:204)
    at com.sun.javafx.scene.control.skin.LabelSkin.handleControlPropertyChanged(LabelSkin.java:49)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase.lambda$registerChangeListener$61(BehaviorSkinBase.java:197)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$$Lambda$195/1183524082.call(Unknown Source)
    at com.sun.javafx.scene.control.MultiplePropertyChangeListenerHandler$1.changed(MultiplePropertyChangeListenerHandler.java:55)
    at javafx.beans.value.WeakChangeListener.changed(WeakChangeListener.java:89)
    at com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:182)
    at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
    at javafx.beans.property.StringPropertyBase.fireValueChangedEvent(StringPropertyBase.java:103)
    at javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:110)
    at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:144)
    at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:49)
    at javafx.beans.property.StringProperty.setValue(StringProperty.java:65)
    at javafx.scene.control.Labeled.setText(Labeled.java:145)
    at anywheresoftware.b4j.objects.LabeledWrapper.setText(LabeledWrapper.java:26)
    at b4j.example.connbilhandler1._handle(connbilhandler1.java:179)
    at sun.reflect.GeneratedMethodAccessor31.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
    at anywheresoftware.b4j.object.JServlet$Handle.run(JServlet.java:115)
    at anywheresoftware.b4j.object.JServlet.Handle(JServlet.java:91)
    at anywheresoftware.b4j.object.JServlet.doPost(JServlet.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:738)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:551)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:219)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1111)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:478)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1045)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
    at org.eclipse.jetty.server.Server.handle(Server.java:462)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:279)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:232)
    at org.eclipse.jetty.io.AbstractConnection$1.run(AbstractConnection.java:534)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:607)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$1.run(QueuedThreadPool.java:536)
    at java.lang.Thread.run(Thread.java:745)
ExecuteMemoryTable: SELECT * FROM Mov_21_08_2015_Linea1 WHERE Operatore = "Antonio Diomede" And Data = "21/08/2015"
.................................

Thanks
 
Last edited:

micro

Well-Known Member
Licensed User
Longtime User
As @billzhan wrote you should not try to create a desktop UI in a server app.

It will probably fail in debug mode as well in some cases.

The threading model is different in release mode (the handler classes are executed by a thread pool).
How can I fix without rewriting all the app?
I also did a test to put the results into a map and send it of a module code, but not work (the map has the correct values)
 
Upvote 0

micro

Well-Known Member
Licensed User
Longtime User
You should create two apps. The server app and the UI app that connects to the server with HttpUtils2.
Then in the same Sub Handle i receive data from the device (client) and the application UI (localhost) on the same port.
There may be conflicts?
Thanks

I have to add another handler? (Server.AddHandler....)
And how to exchange data between two handler?
 
Last edited:
Upvote 0

billzhan

Active Member
Licensed User
Longtime User
Change the port of UI application or/and non-ui(server) application.

Another way : UI and non-ui read/write infomation in shared folder(s), checking the folder with a timer (interval 100ms or 1sec)
 
Upvote 0

micro

Well-Known Member
Licensed User
Longtime User
Excuse if it is OT (New Thread?)
If I have a server with this connection:
B4X:
srv.AddHandler("/conn1", "Conn_1", False)
srv.AddHandler("/conn2", "Conn_2", False)
srv.AddHandler("/conn2", "Conn_3", False)
srv.AddHandler("/connUi", "Connr_Ui", False)
and i would like in hanlde (for example Conn_1) redirect the resp.OutputStream
to Conn_Ui i must use resp.SendRedirect?
If it's yes, in what way?
I used resp.SendRedirect("connUi") and after SendObject(map, resp.OutputStream) and raise event in handle of Conn_1 but not
always and the object received is empty.

Thanks
 
Upvote 0
Top