This site requires JavaScript, please enable it in your browser!
Greenfoot back
edparrish
edparrish wrote ...

2011/7/26

Windows cannot find 'greenfoot.gameserver.address'.

edparrish edparrish

2011/7/26

#
When I uploaded a new version of a scenario, I get a message: "Windows cannot find 'greenfoot.gameserver.address'." Also, my newly uploaded scenario only displays a small square in the middle of the screen until I press the Reset button. I checked out the scenarios on another computer and saw the same result. My prior versions worked correctly, showing much more that a small square in the applet area. My scenarios showing the problem are: http://greenfootgallery.org/scenarios/2370 http://greenfootgallery.org/scenarios/2371 I saw another post where someone reported a similar problem (http://greenfootgallery.org/topics/131). Any ideas on what the problem could be?
mjrb4 mjrb4

2011/7/26

#
In terms of the greenfoot.gameserver.address, that's a known bug with this version of Greenfoot and has been fixed for the next release. As far as I know it shouldn't effect anything though, so I doubt it's to do with your scenarios not loading properly when you press reset (it seems to load ok for me anyway?) Have you used the Java console to check for exceptions?
edparrish edparrish

2011/7/26

#
Thank you for suggesting the Java console to check for exceptions. I am embarrassed that I did not think of that before posting a discussion. I fixed the problem but the cause surprised me. The stack trace was: java.lang.NullPointerException at greenfoot.Greenfoot.getKey(Greenfoot.java:86) at GUIComponent.requestFocus(GUIComponent.java:436) at GUIWorld.<init>(GUIWorld.java:147) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at greenfoot.export.GreenfootScenarioViewer.instantiateNewWorld(GreenfootScenarioViewer.java:303) at greenfoot.export.GreenfootScenarioViewer.init(GreenfootScenarioViewer.java:164) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) The problem was greenfoot.Greenfoot.getKey(). Apparently, calling Greenfoot.getKey() from the constructor of a World class is a bad idea. I was making the call as part of a general method to set the focus of a component, using Greenfoot.getKey() to clear the keyboard buffer. I was surprised that a call to a static method could cause a null pointer exception. However, since the stack trace shows an extra "greenfoot" variable in front of the static method call, there must be something else going on behind the scenes when serving an applet. Since the problem did not show on your system, I assume it has something to do with my Windows XP system running the latest Java.
mjrb4 mjrb4

2011/7/26

#
The greenfoot you see preceding the "Greenfoot" isn't a variable, it's a package, and essentially it's saying the NPE was thrown from within Greenfoot.java on line 86. As you've noted it's an easy problem to work around but it probably is a bug within the Greenfoot file itself. It should probably be changed to just return null in such a scenario rather than throw a NPE.
edparrish edparrish

2011/7/26

#
Thanks for the clarification. I see now that if makes more sense that the "greenfoot" is a package name.
You need to login to post a reply.