Admin zone error on TraceMessageEvtHandler.java:45

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

Moderators: Lapo, Bax

imantexas
Posts: 12
Joined: 10 Dec 2018, 11:59

Admin zone error on TraceMessageEvtHandler.java:45

Postby imantexas » 10 Dec 2018, 12:11

Hello everyone

I'm pretty new here and I'm enjoying using Smartfox engine, it's fantastic,
I got this error every time some one calls a specific function, the function itself works fine and it's pretty much like other functions that I have:

Code: Select all

10 Dec 2018 | 15:30:31,642 | WARN  | SFSWorker:Ext:2 | entities.managers.SFSExtensionManager |     | java.lang.NullPointerException:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: java.lang.NullPointerException
Message: *** Null ***
Description: Error during event handling: java.lang.NullPointerException, Listener: { Ext: Admin, Type: JAVA, Lev: ZONE, { Zone: --=={{{ AdminZone }}}==-- }, {} }
+--- --- ---+
Stack Trace:
+--- --- ---+
com.smartfoxserver.v2.admin.handlers.events.TraceMessageEvtHandler.handleServerEvent(TraceMessageEvtHandler.java:45)
com.smartfoxserver.v2.extensions.SFSExtension.handleServerEvent(SFSExtension.java:259)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchEvent(SFSExtensionManager.java:768)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchZoneLevelEvent(SFSExtensionManager.java:689)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.handleServerEvent(SFSExtensionManager.java:1023)
com.smartfoxserver.v2.core.SFSEventManager$SFSEventRunner.run(SFSEventManager.java:66)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


since it happens in Admin zone I don't know what to do to get rid of it!
thanks for helping
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Admin zone error on TraceMessageEvtHandler.java:45

Postby Lapo » 10 Dec 2018, 14:09

Hi,
what version of SFS2X are you using?
Also, can you explain what is this "specific function" you're using and that triggers the issue?

Maybe show us the relevant code, if it's not too long.

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
imantexas
Posts: 12
Joined: 10 Dec 2018, 11:59

Re: Admin zone error on TraceMessageEvtHandler.java:45

Postby imantexas » 11 Dec 2018, 06:44

Hi Lapo, thanks for quick reply,

I'm using ver. 2.13.1 and sure, here is the code:

Code: Select all

   trace("done getting cards!");

   // give the selected cards to player
        for (int i = 0; i < cards.size(); i++)
        {
            ISFSObject obj = cards.getSFSObject(i);
            GivePlayerCards(_userID, obj.getInt("id"), obj.getInt("count"));
        }

and:

Code: Select all

    private void GivePlayerCards(int _userID, int _itemID, int _count) throws SQLException, NoSuchAlgorithmException
    {
        sql = connection.prepareStatement("SELECT id FROM user_item_unlocks WHERE user_id=? AND item_id = ? AND deleted IS NULL");
        sql.setInt(1, _userID);
        sql.setInt(2, _itemID);
        result = sql.executeQuery();
        if (result.isBeforeFirst()) // player already unlocked this item so just increase the cards
        {
            result.next();
            sql = connection.prepareStatement("UPDATE user_item_unlocks SET cards = cards + ?, gained = gained + ? WHERE id=?");
            sql.setInt(1, _count);
            sql.setInt(2, _count);
            sql.setInt(3, result.getInt("id"));
            sql.executeUpdate();
        }
        else // unlock the item for player
        {
            sql = connection.prepareStatement("INSERT INTO user_item_unlocks (user_id, item_id, cards, created) VALUES(?, ?, ?, ?)");
            sql.setInt(1, _userID);
            sql.setInt(2, _itemID);
            sql.setInt(3, _count);
            sql.setString(4, Utility.GetTimeString(0));
            sql.executeUpdate();
        }
    }


I know it throws the exception here cause I can see the "done getting cards!" in the log before the error.
thanks
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Admin zone error on TraceMessageEvtHandler.java:45

Postby Lapo » 11 Dec 2018, 08:42

Hi,
I am not sure the code you have posted is the cause of the error.
The stack trace indicates that the NPE is thrown inside the AdminTool while handling a trace message. This means that the trigger of the error is caused by a call to the trace() method inside the Extension.

What I would expect is that a call to trace() is passing a null parameter and cause the issue.

Can you double check?
Lapo

--

gotoAndPlay()

...addicted to flash games
imantexas
Posts: 12
Joined: 10 Dec 2018, 11:59

Re: Admin zone error on TraceMessageEvtHandler.java:45

Postby imantexas » 11 Dec 2018, 10:46

You are right Lapo, I had a line of code like this:

Code: Select all

trace("done getting cards! ----------------------------");


and for some reason trace() couldn't handle "--------------------------" part! I removed "-----------------" and the error is gone now.

oh wait now it throes this error:

Code: Select all

11 Dec 2018 | 14:21:25,428 | WARN  | SFSWorker:Ext:1 | entities.managers.SFSExtensionManager |     | java.lang.NullPointerException:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: java.lang.NullPointerException
Message: *** Null ***
Description: Error during event handling: java.lang.NullPointerException, Listener: { Ext: Admin, Type: JAVA, Lev: ZONE, { Zone: --=={{{ AdminZone }}}==-- }, {} }
+--- --- ---+
Stack Trace:
+--- --- ---+
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Admin zone error on TraceMessageEvtHandler.java:45

Postby Lapo » 11 Dec 2018, 15:42

Are you really sure that's the cause?
I don't think a simple trace() like that can cause such error. Otherwise this would be a super common problem every time you try to log something, which it isn't.
Lapo

--

gotoAndPlay()

...addicted to flash games
imantexas
Posts: 12
Joined: 10 Dec 2018, 11:59

Re: Admin zone error on TraceMessageEvtHandler.java:45

Postby imantexas » 13 Dec 2018, 15:19

I'm not sure but I changed that one line of code and the error message changed, so it should be!
I didn't find anything else yet i'll let you know,

cheers

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 13 guests