Android Question CloudKVS Server on B4A

themr23

Member
Licensed User
I gave this a shot hoping to prove out it can run (should be able to, right) on B4A on a tablet.
Can you please take a look and give me some guidance?
It is getting an object to string[] conversion exception in GetUserItems in DB at
Dim rs As ResultSet = sql.ExecQuery2(...

I would expect it to work with the B4J or B4A CloudKVS clients.
Thanks,
-Chris

** Service (starter) Create **
** Service (starter) Start **
Start
CloudKVS server.
Version = 0.9.
Listening on port: 51042
Ip address: 10.10.10.154
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
SS_NC true
ASND 362
POST /action HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Content-Length: 168
Host: 10.10.10.154:51042
Connection: Keep-Alive
Accept-Encoding: gzip
User-Agent: okhttp/2.4.0
x��`�g``H2I�K�H�-�I�K��/M�.+��M��S�/I,�f*a��Şy�%��9�U�)쌌@��ϒ�\ B&e��Lb��▙����
p�Z V���0r�l��M�����ejP,Z�ZQ��2r��ĜR�b�k�sSR�%�@M�����H�
ASND.
168
Class not found: b4a.example.cloudkvs.main$_task, trying: b4a.example.cloudkvs.server.main$_task
Class not found: b4a.example.cloudkvs.main$_item, trying: b4a.example.cloudkvs.server.main$_item
1497159327922 Task: getuser_u1, User: u1, Key: 0
(ClassCastException) java.lang.ClassCastException: java.lang.Object[] cannot be cast to java.lang.String[]
items 0
items to bytes 11
AS Terminated

By the way it would not run with wal mode (journal mode to wal), so I had turned that off to get as far as I did in the uploaded project.

Thank you
-Chris
 

themr23

Member
Licensed User
Use Case is: I'd rather not leave a PC running for a low intensity application, and I have an old tablet ('Otter' running CM).

Using B4A 6.50.

Update: Fixed this issue, see two posts down

B4X:
LogCat connected to: B4A-Bridge: android Amazon Otter
--------- beginning of /dev/log/main
** Service (starter) Create **
** Service (starter) Start **
Start
CloudKVS server.
Version = 0.9.
Listening on port: 51042
Ip address: 10.10.10.154
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
SS_NC true
ASND 303
POST /action HTTP/1.1

Content-Length: 158

Content-Type: application/x-www-form-urlencoded

Host: 10.10.10.154:51042

Connection: Keep-Alive



x��`c``H2��K�H�-�I��M��S�/I,�f�0�    �bϼ̒�Ĝ̪�vFF�XP�_bn*#���ZRZ�Z_j��,I͕�ax&P�
��@�P�an��9)�L@�T��J�����Ĝ�T�(#;Ȱ0��?�M�̅�aq��lj#�����A�
ASND.
158
Class not found: b4j.example.main$_task, trying: b4a.example.cloudkvs.server.main$_task
Class not found: b4j.example.main$_item, trying: b4a.example.cloudkvs.server.main$_item
1497321456466 Task: getuser_u1, User: u1, Key: 32
db_getuseritems (B4A line: 61)
Dim rs As ResultSet = sql.ExecQuery2("SELECT key,
java.lang.ClassCastException: java.lang.Object[] cannot be cast to java.lang.String[]
    at b4a.example.cloudkvs.server.db._getuseritems(db.java:203)
    at b4a.example.cloudkvs.server.action._handlebuf(action.java:84)
    at b4a.example.cloudkvs.server.starter._astream_newdata(starter.java:240)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at anywheresoftware.b4a.BA$2.run(BA.java:328)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5146)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
    at dalvik.system.NativeStart.main(Native Method)
java.lang.RuntimeException: java.lang.ClassCastException: java.lang.Object[] cannot be cast to java.lang.String[]
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:206)
    at anywheresoftware.b4a.BA$2.run(BA.java:328)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5146)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: java.lang.Object[] cannot be cast to java.lang.String[]
    at b4a.example.cloudkvs.server.db._getuseritems(db.java:203)
    at b4a.example.cloudkvs.server.action._handlebuf(action.java:84)
    at b4a.example.cloudkvs.server.starter._astream_newdata(starter.java:240)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    ... 10 more
** Activity (main) Resume **
 
Last edited:

themr23

Member
Licensed User
Ah. This did not cause an exception.

B4X:
    Dim rs As ResultSet = sql.ExecQuery2("SELECT key, value, id, time FROM data WHERE user = ? AND id > ?", Array As String(user,lastId))
 

Erel

Administrator
Staff member
Licensed User
This line is wrong:
B4X:
Dim arrayargs() As String = Array(user,lastId)
It should be:
B4X:
Dim arrayargs() As String = Array As String(user,lastId)
 

DonManfred

Expert
Licensed User
First of all, many thanks for this great solution!
For my projects, It is not the best solution to use the BLOB as data type to store. I would prefer to use String for stored values. Is it possible to implement at the ClientKVS client (B4A) and CloudKVS_Server?
1. You should NEVER post to an existing thread. ALWAYS create a new thread for your question.
2. This is NOT the right place for wishes. You should create a thread in the bugs and wishlist forum instead.
 

b4xscripter

Member
Licensed User
Sorry, DonManfred...
I just wanted to put the context to my question. Ok please, remove my post and I will create a new thread.

Best regards
 

DonManfred

Expert
Licensed User
I can not delete it! I am a User like you.
Leave the thread as it and just create a new one in the right forum.

For the future; just stop posting to exiting threads and post your question always in a new thread (in the right forum for sure :)).
 

b4xscripter

Member
Licensed User
Following the Erel's suggestion, I just put it in Android Questions. I hope this is a correct place. Anyway, thank you a lot, guys, for your help!

Best regards
 
Top