java.lang.NullPointerException - NEED HELP!

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

User avatar
WoWoX
Posts: 16
Joined: 18 May 2013, 13:25

java.lang.NullPointerException - NEED HELP!

Postby WoWoX » 16 Sep 2013, 15:53

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";
    gotoAndPlay(connect);
    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
rException
Exception type: java.lang.NullPointerException
java.lang.NullPointerException
        at it.gotoandplay.smartfoxserver.extensions.JavascriptExtension.logASErr
or(JavascriptExtension.java:668)
        at it.gotoandplay.smartfoxserver.extensions.JavascriptExtension.handleRe
quest(JavascriptExtension.java:273)
        at it.gotoandplay.smartfoxserver.controllers.ExtensionHandler.processEve
nt(ExtensionHandler.java:454)
        at it.gotoandplay.smartfoxserver.controllers.ExtensionHandler.run(Extens
ionHandler.java:344)
        at java.lang.Thread.run(Thread.java:619)


Any suggestions on what i should do?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: java.lang.NullPointerException - NEED HELP!

Postby rjgtav » 16 Sep 2013, 23:41

Hi,

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
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 4 guests