B4J Question B4I send raf data to b4j server, but get the error.

tzfpg

Active Member
Licensed User
here is my b4i code:
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Private Pg3 As Page
    Public lbl_name As Label
    Private adp As AnotherDatePicker
    Private btn_date As Button
    Dim clv2 As CustomListView
    Dim alist As List
    Private raf As RandomAccessFile
    Type AttendeeDetailValue(Attended_Date As String,Attendee As String)
End Sub

Sub SendValue(Attended_Date As String,Attendee As String)
    Dim a As AttendeeDetailValue
    a.Initialize
    a.Attended_Date=Attended_Date
    a.Attendee = Attendee
    SendObject(a)
End Sub

Sub SendObject (Obj As Object)
   raf.WriteB4XObject(Obj,0)
   Dim size As Int = raf.CurrentPosition
   Dim data(size) As Byte
   raf.CurrentPosition = 0
   Do While raf.CurrentPosition < size
         raf.ReadBytes(data, raf.CurrentPosition, size - raf.CurrentPosition, _
           raf.CurrentPosition)
   Loop
 
   Dim j As HttpJob
   j.Initialize("send object", Me)
   j.PostBytes(staff_location.link & "/Attendee_Detail", data)
End Sub
and here is my b4j code:

B4X:
Public Sub Handle(req As ServletRequest, resp As ServletResponse)

    Dim raf As RandomAccessFile
    raf.Initialize3(Bit.InputStreamToBytes(req.InputStream), False)
       Dim AttendeeDetail1 As AttendeeDetailValue= raf.ReadB4XObject(0)
    Dim Attendee As String=AttendeeDetail1.Attendee
    Dim attended_Date As String=AttendeeDetail1.Attended_Date
    Log(Attendee)
    Log(attended_Date)
'    Dim sql1 As SQL = Main.mysql_pool1.GetConnection
'    Dim results As List
'    results.Initialize
'    Dim Map1 As Map
'    Map1 = File.ReadMap(File.DirApp, "config.properties")
'    Dim mysql_pool_Select_Update_Lift_Shutdown As String = Map1.Get("sql.update_lift_shutdown")
'    sql1.ExecNonQuery2(mysql_pool_Select_Update_Lift_Shutdown, Array As Object(Attendee_Detail1.Attended_Date,Attendee_Detail1.Attendee))
'    Main.SendObject(results, resp)
'    sql1.Close
   
   
End Sub
here is my error message:
B4X:
Error occurred on line: 15 (attendee_detail).
java.lang.RuntimeException: java.lang.IllegalArgumentException: Can not set boolean field com.tzfelevator.server.main$_attendeedetailvalue.IsInitialized to java.lang.Integer
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readType(B4XSerializator.java:200)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:249)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ReadObject(B4XSerializator.java:46)
    at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.ReadB4XObject(RandomAccessFile.java:309)
    at com.tzfelevator.server.attendee_detail._handle(attendee_detail.java:54)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:563)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:221)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:156)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:82)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
    at anywheresoftware.b4j.object.JServlet$Handle.run(JServlet.java:115)
    at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
    at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
    at anywheresoftware.b4a.ShellBA.startMessageLoop(ShellBA.java:103)
    at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:131)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:292)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:156)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:82)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
    at com.tzfelevator.server.main.main(main.java:29)
Caused by: java.lang.IllegalArgumentException: Can not set boolean field com.tzfelevator.server.main$_attendeedetailvalue.IsInitialized to java.lang.Integer
    at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:164)
    at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:168)
    at sun.reflect.UnsafeBooleanFieldAccessorImpl.set(UnsafeBooleanFieldAccessorImpl.java:86)
    at java.lang.reflect.Field.set(Field.java:680)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readType(B4XSerializator.java:195)
    ... 32 more
what wrong with my code, i cant get the value from b4i.
please help me. thanks!
 
Top