the_big_blackbox the_big_blackbox - 1 year ago 59
Java Question

java null pointer exception

Based on different SO questions I understand what the java.null.pointer exception is I am just not sure why it occurs in this case. In summary a reference to a variable declared as a reference type not yet defined.

I have 2 java files and

The following call in the file results in a java.null.pointer exception:

AppController.getInstance().addToRequestQueue(strReq, tag_string_req);

This is the method in the AppController file:

public static synchronized AppController getInstance() {
return mInstance;

public class AppController extends Application {

public static final String TAG = AppController.class.getSimpleName();

private RequestQueue mRequestQueue;

private static AppController mInstance;

public void onCreate() {
mInstance = this;

public static synchronized AppController getInstance() {
return mInstance;

public class RegisterActivity extends Activity {
private void registerUser(final String name, final String email,
final String password) {
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);


07-01 16:33:17.757 995-995/mobi.blessd.user.blessd E/AndroidRuntime: FATAL EXCEPTION: main
Process: mobi.blessd.user.blessd, PID: 995
at mobi.blessd.user.blessd.activity.RegisterActivity.registerUser(
at mobi.blessd.user.blessd.activity.RegisterActivity.access$300(
at mobi.blessd.user.blessd.activity.RegisterActivity$1.onClick(
at android.view.View.performClick(
at android.view.View$
at android.os.Handler.handleCallback(
at android.os.Handler.dispatchMessage(
at android.os.Looper.loop(
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(
at dalvik.system.NativeStart.main(Native Method)

My source code is from the following tutorial

Answer Source

Did you add the AppControler to your manifest?

        android:name=".AppController" //this one