Servlet exception

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

sitz
Posts: 14
Joined: 05 Aug 2019, 16:07

Servlet exception

Postby sitz » 31 Aug 2021, 23:51

Working from the tomcat servlet example. It's throwing an exception that it can't find the zone but I don't understand why. The only change is the package & zone name.

rootCause.png
(3.26 KiB) Not downloaded yet

servlet.png
(59.11 KiB) Not downloaded yet

RKEzone.png
(32.85 KiB) Not downloaded yet
sitz
Posts: 14
Joined: 05 Aug 2019, 16:07

Re: Servlet exception

Postby sitz » 31 Aug 2021, 23:52

RKEzone.png
(32.85 KiB) Not downloaded yet

zone extension.png
(17.24 KiB) Not downloaded yet

extension code.png
(14.69 KiB) Not downloaded yet
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Servlet exception

Postby Lapo » 01 Sep 2021, 07:57

Hi,
the code looks fine. I would suggest to break down line 33 into single calls to better understand which is the object that is causing the NPE.

What version of SFS2X are you using?
Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
sitz
Posts: 14
Joined: 05 Aug 2019, 16:07

Re: Servlet exception

Postby sitz » 01 Sep 2021, 16:28

2.17.0

I'll break the call down and see what happens. Back soon.
sitz
Posts: 14
Joined: 05 Aug 2019, 16:07

Re: Servlet exception

Postby sitz » 03 Sep 2021, 17:12

Same issue no matter how I try to declare it. Even added the code to a room extension and tried to pull that.

line41.png
(10.27 KiB) Not downloaded yet

line42.png
(10.61 KiB) Not downloaded yet

line44.png
(11.38 KiB) Not downloaded yet
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Servlet exception

Postby Lapo » 04 Sep 2021, 07:11

That the issue wouldn't go away it was expected, however breaking down the code in single calls helps understanding which of the object is causing the NPE.
So which one is it? Is it the ZoneManager? The Zone? The Room?

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
sitz
Posts: 14
Joined: 05 Aug 2019, 16:07

Re: Servlet exception

Postby sitz » 05 Sep 2021, 23:30

Lapo wrote:That the issue wouldn't go away it was expected, however breaking down the code in single calls helps understanding which of the object is causing the NPE.
So which one is it? Is it the ZoneManager? The Zone? The Room?

Thanks


My bad, it throws it on the zone object when trying to get the zone extension or any rooms using get by name & get by ID.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Servlet exception

Postby Lapo » 06 Sep 2021, 08:19

If this is reproducible 100% of the times I think it's a symptom of some other problem.
Zones are created before the http-server is started and there is no way a certain Zone X isn't ready by the time servlets are invoked (the startup process is also mono-threaded).

The question is: are you sure the Zone you are targeting with your servlet is created without errors? I'd recommend double checking the SFS2X logs at startup time.

I am not sure what else could cause an NPE like that, other than using the wrong Zone name.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
sitz
Posts: 14
Joined: 05 Aug 2019, 16:07

Re: Servlet exception

Postby sitz » 06 Sep 2021, 15:39

The zone loads fine on startup, no errors. Several apps (Unity developed) connect, join that zone, then join rooms and play their games. The zone and room extensions work very well.

It picks up the Zone from the Zone manager without returning any errors, but I can't get anything out of the Zone object after that. I've called the zone by name and zone ID and it is always the same outcome. I'll keep working on it when I have time. Is it possibly because I have an old zone configuration file that was made in ... probably 2.13?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Servlet exception

Postby Lapo » 06 Sep 2021, 15:52

Hi,
no, the zone file coming from an older version is not an issue. A Zone file contains XML that defines the properties of that Zone, if the server can load it without errors, there is no problem.

I can suggest a test to perform: in your init() servlet code try calling the ZoneManager.getZoneList() method. It has the following signature:

Code: Select all

public List<Zone> getZoneList()

Then see what the returned list contains. Normally you should find all your custom defined Zones plus the Admin Zone.

Let us know what you find.
Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
sitz
Posts: 14
Joined: 05 Aug 2019, 16:07

Re: Servlet exception

Postby sitz » 06 Sep 2021, 18:35

sfs = SmartFoxServer.getInstance();
List<Zone> newList = sfs.getZoneManager().getZoneList();
msg = String.valueOf(newList.size());


with the getWriter.write(msg) in doGet's first line. Returns 0. No zones in the manager then.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Servlet exception

Postby Lapo » 07 Sep 2021, 06:43

We have no idea how to reproduce this, sorry. :?
At this point I am inclined to think that there're "hidden variables" in this specific issues, e.g. something else is not being accounted for.

We can take release 2.17.0 version out of the box and add a basic servlets that lists the Zones using this code:

Code: Select all

   @Override
   public void init() throws ServletException
   {
      sfs = SmartFoxServer.getInstance();

      List<Zone> zones = sfs.getZoneManager().getZoneList();
      System.out.println("Zone(s) List: " + zones);
      
   }


And it always returns the expected list of Zones.

Code: Select all

Zone(s) List: [{ Zone: --=={{{ AdminZone }}}==-- }, { Zone: BasicExamples }


If you want to send us your current compiled servlet we can take a further look and test it locally. At least we can see if the behavior is consistent. To do so, send us an email to our support@... email box with a reference to this thread.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
sitz
Posts: 14
Joined: 05 Aug 2019, 16:07

Re: Servlet exception

Postby sitz » 08 Sep 2021, 16:07

I can't get it to return any zone. Possible something with eapps and this docker image, I'm going to set it up on Overcast and see if the issue persists.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Servlet exception

Postby Lapo » 09 Sep 2021, 09:53

Yeah, that sounds like a broken installation.
Lapo

--

gotoAndPlay()

...addicted to flash games
sitz
Posts: 14
Joined: 05 Aug 2019, 16:07

Re: Servlet exception

Postby sitz » 15 Oct 2021, 19:24

I've tried your sample code on a fresh 2.17.3 install on linux on eapps and another on an amazon aws ec2 windows instance. returns the correct version, but the zone list is always []

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Stevenor and 71 guests