B4J Question ArrayList cannot be cast

Peter Lewis

Well-Known Member
Licensed User
Longtime User
Hi,
I have been using this code for many programs and it was working in this program for the past 2 weeks. Now the program is spitting out an error on the last line of the code. Any Ideas ? Thank you


B4X:
    Dim query As String = $"
    Select [customer_id]
    ,[customer_contact_name]
    ,[customer_company_name]
    ,[customer_type]
    FROM [ledposter].[dbo].[customer_information]
    where customer_type = ?
    "$
    Dim dt As dataTable
    dt.Initialize(sql,query,Array As String("Owner"))
    Dim ownerinfo As List
    ownerinfo.Initialize

    For p = 0 To dt.RowsCount-1
        Dim game As Map = dt.getRowMapValues(p)
        ownerinfo.Add(game)
    Next
    Return ownerinfo

Error occurred on line: 210 (clsMallInfoAdd)
java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class java.util.Map (java.util.ArrayList and java.util.Map are in module java.base of loader 'bootstrap')
at b4j.example.clsmallinfoadd._handle(clsmallinfoadd.java:268)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
at anywheresoftware.b4j.object.JServlet$Handle.run(JServlet.java:146)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:47)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:43)
at anywheresoftware.b4a.shell.ShellBA.startMessageLoop(ShellBA.java:121)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:181)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:309)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
at b4j.example.main.main(main.java:29)
 

Peter Lewis

Well-Known Member
Licensed User
Longtime User
you are !00 % correct. I am however surprised it was working as a map


B4X:
    Dim custinfo As Map = loadinfo(sql,Main.customer_id)
    Dim ownerinfo As List = loadowner(sql)
    Dim mallinfo As List = loadmalltable(sql)
    Dim provinceinfo As List = loadprovincetable(sql)
    Dim municipalityinfo As List = loadmunicipalitytable(sql)
    Dim suburbinfo As List = loadsuburbtable(sql)

Now Changed
 
Upvote 0
Top