Error: java.lang.NullPointerException

daveg

New Member
Licensed User
Longtime User
Hi there

I had my program working where it would read data from my website (based on one of
your example)


http://MyClubDiary.com/MobileData.aspx


HttpUtils.PostString("Job1", ServerUrl, "Event")

http://myclubdiary.com/MobileData.aspx?query=Event
http://myclubdiary.com/MobileData.aspx?query=Home


I then started getting this error message

java.lang.NullPointerException

The statement

If HttpUtils.IsSuccess(ServerUrl) Then

Is returning false


and cant seem to getting working again



Any ideas?

Thanks

Dave



HERES THE LOG
==============



>>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
CheckJNI is ON


--- registering native functions ---
GC_EXPLICIT freed 130 objects / 7056 bytes in 124ms
Scanning package: /data/app/vmdl26880.tmp
Removing non-system package:anywheresoftware.b4a.samples.sqlserver
Force stopping package anywheresoftware.b4a.samples.sqlserver uid=10044
Scanning package anywheresoftware.b4a.samples.sqlserver
Package anywheresoftware.b4a.samples.sqlserver codePath changed from /data/app/anywheresoftware.b4a.samples.sqlserver-1.apk to /data/app/anywheresoftware.b4a.samples.sqlserver-2.apk; Retaining data and using new
/data/app/anywheresoftware.b4a.samples.sqlserver-2.apk changed; unpacking
DexInv: --- BEGIN '/data/app/anywheresoftware.b4a.samples.sqlserver-2.apk' ---
DexOpt: load 147ms, verify 489ms, opt 17ms
DexInv: --- END '/data/app/anywheresoftware.b4a.samples.sqlserver-2.apk' (success) ---
Code path for pkg : anywheresoftware.b4a.samples.sqlserver changing from /data/app/anywheresoftware.b4a.samples.sqlserver-1.apk to /data/app/anywheresoftware.b4a.samples.sqlserver-2.apk
Resource path for pkg : anywheresoftware.b4a.samples.sqlserver changing from /data/app/anywheresoftware.b4a.samples.sqlserver-1.apk to /data/app/anywheresoftware.b4a.samples.sqlserver-2.apk
Services: anywheresoftware.b4a.samples.sqlserver.httputilsservice
Receivers: anywheresoftware.b4a.samples.sqlserver.httputilsservice$httputilsservice_BR
Activities: anywheresoftware.b4a.samples.sqlserver.main
Force stopping package anywheresoftware.b4a.samples.sqlserver uid=10044
move /data/dalvik-cache/data@[email protected]@classes.dex -> /data/dalvik-cache/data@[email protected]@classes.dex
New package installed in /data/app/anywheresoftware.b4a.samples.sqlserver-2.apk
Force stopping package anywheresoftware.b4a.samples.sqlserver uid=10044
GC_EXPLICIT freed 9379 objects / 585304 bytes in 175ms
GC_EXPLICIT freed 1245 objects / 73408 bytes in 184ms
no available voice recognition services found
GC_EXPLICIT freed 4054 objects / 222312 bytes in 199ms
unlink /data/dalvik-cache/data@[email protected]@classes.dex
Shutting down VM
adbd disconnected
NOTE: attach of thread 'Binder Thread #3' failed

>>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
CheckJNI is ON
--- registering native functions ---
Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=anywheresoftware.b4a.samples.sqlserver/.main }
** Activity (main) Pause, UserClosed = false **
Shutting down VM
Start proc anywheresoftware.b4a.samples.sqlserver for activity anywheresoftware.b4a.samples.sqlserver/.main: pid=426 uid=10044 gids={3003}
adbd disconnected
JNI: AttachCurrentThread (from ???.???)
NOTE: attach of thread 'Binder Thread #3' failed
Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@44ff84e8 (uid=10044 pid=426)


Client not active, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4502eda8


Displayed activity anywheresoftware.b4a.samples.sqlserver/.main: 1353 ms (total 1353 ms)


** Activity (main) Create, isFirst = true **


GC_FOR_MALLOC freed 6819 objects / 332624 bytes in 89ms


Starting Job: Job1


** Activity (main) Resume **


** Service (httputilsservice) Create **


** Service (httputilsservice) Start **


GC_EXPLICIT freed 85 objects / 3384 bytes in 267ms


GC_EXPLICIT freed 167 objects / 12528 bytes in 180ms


GC_EXPLICIT freed 44 objects / 2112 bytes in 230ms


java.net.UnknownHostException: MyClubDiary.com


at java.net.InetAddress.lookupHostByName(InetAddress.java:513)


at java.net.InetAddress.getAllByNameImpl(InetAddress.java:278)


at java.net.InetAddress.getAllByName(InetAddress.java:242)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:136)


at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:348)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)


at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
at anywheresoftware.b4a.http.HttpClientWrapper$3.run(HttpClientWrapper.java:211)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)


at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)


at java.lang.Thread.run(Thread.java:1096)
Error. Url=http://MyClubDiary.com/MobileData.aspx Message=java.net.UnknownHostException: MyClubDiary.com
GC_FOR_MALLOC freed 9958 objects / 502056 bytes in 277ms


main_jobdone (B4A line: 63)


For i = 0 To rows.Size - 1



java.lang.NullPointerException
at anywheresoftware.b4a.samples.sqlserver.main._jobdone(main.java:385)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:89)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:772)
at anywheresoftware.b4a.keywords.Common.CallSub2(Common.java:759)
at anywheresoftware.b4a.samples.sqlserver.httputilsservice._processnexttask(httputilsservice.java:244)
at anywheresoftware.b4a.samples.sqlserver.httputilsservice._hc_responseerror(httputilsservice.java:154)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
at anywheresoftware.b4a.BA$1.run(BA.java:210)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)


at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
java.lang.NullPointerException





HERES MY MAIN SOURCE CODE
=======================
'Activity module
Sub Process_Globals
Dim ServerUrl As String
ServerUrl = "http://MyClubDiary.com/MobileData.aspx"

End Sub

Sub Globals
Dim ListView1 As ListView
'Dim pnlToolBox As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)

Activity.LoadLayout("1")

ListView1.SingleLineLayout.Label.TextSize = 10
ListView1.Width = 100%x
'pnlToolBox.Top=Activity.Height-pnlToolBox.Height
'ListView1.Height=pnlToolBox.Top-ListView1.Top-10dip

Activity.AddMenuItem("Kill process", "mnuKillProcess")

If FirstTime Then
HttpUtils.CallbackActivity = "Main"
HttpUtils.CallbackJobDoneSub = "JobDone"
End If

HttpUtils.PostString("Job1", ServerUrl, "Event")
End Sub

Sub Activity_Resume

UpdateBlogs

If HttpUtils.Complete = True Then JobDone(HttpUtils.Job)
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub JobDone (Job As String)
If HttpUtils.IsSuccess(ServerUrl) Then
Dim parser As JSONParser
Dim response As String
response = HttpUtils.GetString(ServerUrl)
parser.Initialize(response)
Dim rows As List
rows = parser.NextArray

'work with result
'rows is a List. Each item is a Map with the columns names as keys and the db values as the values.
For i = 0 To rows.Size - 1
'Log("Rows #" & i)
Dim m As Map
m = rows.Get(i)
Log("BlogText=" & m.Get("BlogFrom")) 'log the values of col1 and col2
' Log("col2=" & m.Get("col2"))
Next
End If
ListView1.Clear
For i = 0 To rows.Size - 1
m = rows.Get(i)
ListView1.AddTwoLines( m.Get("BlogFrom"),m.Get("BlogText"))
Next

HttpUtils.Complete = False

End Sub
Sub UpdateBlogs





End Sub





Thanks

Dave
 
Top