Bug? java.lang.NullPointerException: Attempt to read from field 'anywheresoftware.b4a.BA anywheresoftware

Gary Milne

Active Member
Licensed User
Longtime User
I've distilled the issue as much as possible and this is it.

If I take the very simple code below and place it into a brand new project I can run that project and use the debugger to step into the DBUtils.InsertMaps Sub.

Now I take that exact same code and place it into my real project. When I attempt to use the debugger to step into the first line of the DBUtils.InsertMaps Sub it crashes every time with the above message.

B4X:
Sub Write_Session_Master_Record(ShowMessages As Boolean) As Boolean
        Dim X As SQL
        Dim Y As String
        Dim Z As List
       
        Try
            DBUtils.InsertMaps(X, Y, Z)
        Catch
            Log(LastException.Message)
            ToastMessageShow("Error creating new session",True)
        End Try
End Sub

This is the full error message.
Error occurred on line: 135 (SK_SMR_)
java.lang.NullPointerException: Attempt to read from field 'anywheresoftware.b4a.BA$SharedProcessBA anywheresoftware.b4a.BA.sharedProcessBA' on a null object reference
at anywheresoftware.b4a.B4AClass$ImplB4AClass.getActivityBA(B4AClass.java:20)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:302)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

I'm using B4A 5.02(1) and the B4AShared.jar is dated 6/14/2015 @ 5:50PM.

Now I'm guessing you will tell me to get the latest version so I will do that and append to this if the issue goes away.
 

Gary Milne

Active Member
Licensed User
Longtime User
Just test 5.20 and it blows up in the same way.
B4AShared is 8/25/2015 @ 12:48PM
 

DonManfred

Expert
Licensed User
Longtime User
DBUtils.InsertMaps(X, Y, Z)
X, Y and Z are null at this point. What did you expect to happen instead of an nullpointer-exception?
 

Gary Milne

Active Member
Licensed User
Longtime User
X, Y and Z are null at this point. What did you expect to happen instead of an nullpointer-exception?
It does not matter that they are Nul, the contents of those variables are not looked at until it gets well into the DBUtils code module, however it crashes upon trying to enter the DBUtils module. Per my post that same code works on a brand new project as far as being able to step into the DBUtils module. Sure this code will crash later on but that is irrelevant to the problem. I just did it this way to shorten my code.
 

Gary Milne

Active Member
Licensed User
Longtime User
I will do that tomorrow. Where do I upload it to?
 

Gary Milne

Active Member
Licensed User
Longtime User
Can you upload your full project?
I just sent this to your e-Mail along with instructions on how to generate the error.

Thx.
 

Gary Milne

Active Member
Licensed User
Longtime User
This issue is now resolved. I was using Moshiane's Google Charts class and it was generating a number of "Variable name is the same as a module name. This can cause......"

After change the class name to clsPB_ to eliminate the errors (based on a suggestion from Erel) the project now runs as expected. I try not to modify downloaded classes if possible so I had let this warning slide, until now.
 

Walter Adriano da Silva

Member
Licensed User
Longtime User
What means this line? What would be a SharedProccessBA?
java.lang.NullPointerException: Attempt to read from field 'anywheresoftware.b4a.BA$SharedProcessBA anywheresoftware.b4a.BA.sharedProcessBA' on a null object reference
 

Walter Adriano da Silva

Member
Licensed User
Longtime User
B4A Version: 5.50

Error occurred on line: 123 (JSONHandler)
java.lang.NullPointerException: Attempt to read from field 'anywheresoftware.b4a.BA$SharedProcessBA anywheresoftware.b4a.BA.sharedProcessBA' on a null object reference
at anywheresoftware.b4a.B4AClass$ImplB4AClass.getActivityBA(B4AClass.java:20)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:697)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:336)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:246)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
at com.softvale.appcomercial.httpservice._dispatchdataorhandleerror(httpservice.java:832)
at com.softvale.appcomercial.httpservice._resolveeventfromtask(httpservice.java:1588)
at com.softvale.appcomercial.httpservice._jobsuccess(httpservice.java:1525)
at com.softvale.appcomercial.httpservice._jobdone(httpservice.java:1302)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:697)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:246)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.BA$2.run(BA.java:328)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
 

Walter Adriano da Silva

Member
Licensed User
Longtime User
Currently DispatchDataOrHandleError:

B4X:
Private Sub DispatchDataOrHandleError(Job As HttpJob, EventIndexMap As Map)
    For Each EventName As String In EventIndexMap.Keys
        Dim ViewRecord_ As ViewRecord
        Dim ErrorJSON As JSONHandler      
      
        ViewRecord_ = EventIndexMap.Get(EventName)      
        ErrorJSON.Initialize(Job.GetString, "ServiceErrors")
      
        If Not(ErrorJSON.HasContent) Then
            Dim cb As Callback
            cb.Initialize
            cb.EventName = EventName
            cb.Module = Me
          
            DispatchEvent(Job, ViewRecord_, cb)
        Else
            HandleError(ErrorJSON, EventName, Job.Tag)
        End If
    Next
End Sub

Now the app crash and show this on log:

An error occurred:
(Line: 0) DispatchEvent(Job, ViewRecord_, cb)
java.lang.Exception: Sub initialize2 signature does not match expected signature.
public static anywheresoftware.b4a.pc.RemoteObject com.softvale.appcomercial.tao.jsonhandler_subs_0._initialize2(anywheresoftware.b4a.pc.RemoteObject,anywheresoftware.b4a.pc.RemoteObject,anywheresoftware.b4a.pc.RemoteObject) throws java.lang.Exception
 
Top