Page 1 of 1

java.lang.NullPointerException - NEED HELP!

Posted: 16 Sep 2013, 15:53
by WoWoX
Hi, i am receiving this error :

Code: Select all

[ WARNING ] > Exception in ExtensionHandler:ava.lang.NullPointerException.

I will try to provide as much information as i can.

Ok so im trying to make it so when you click the male button, it makes your gender "1" in the database, and if you click the female button, it makes your gender "2".

Here is the code i am using in the extension:

Code: Select all

   function newGender (params, user, dataObj) {
     //userGender = params.Gender
   userGender = gender
   newUser = user.getName();
   var sql = "UPDATE users SET gender = '"+userGender+"' WHERE username='"+newUser+"'";
    var queryRes = dbase.executeCommand(sql)
   //_server.sendResponse (vResp,-1,null,ul);
   trace("gender for "+newUser)
   trace("was changed to>"+userGender)

and here is the code that i am using on the buttons in the game:

Code: Select all

on (release)
    var dataObj = {};
    dataObj.gender = "2";
    smartfox.sendXtMessage("DatabaseLoginEXT", "newGender", dataObj);

When i click the button, i get this error in the cmd window:

Code: Select all

11:14:55.986 - [ WARNING ] > Exception in ExtensionHandler: java.lang.NullPointe
Exception type: java.lang.NullPointerException
        at it.gotoandplay.smartfoxserver.extensions.JavascriptExtension.logASErr
        at it.gotoandplay.smartfoxserver.extensions.JavascriptExtension.handleRe
        at it.gotoandplay.smartfoxserver.controllers.ExtensionHandler.processEve

Any suggestions on what i should do?

Re: java.lang.NullPointerException - NEED HELP!

Posted: 16 Sep 2013, 23:41
by rjgtav

The error you're getting means that you're trying to work with something that is null.
By taking a quick look at your code, I'd say that your error is probably on this line:

Code: Select all

userGender = gender

A good way to find out what exactly is happening at your code and why it is happening, is by tracing.

Hope this helps