www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: AGP on June 16, 2009, 01:11:06 am

Title: java.security.AccessControlException: access denied
Post by: AGP on June 16, 2009, 01:11:06 am
This error is produced by
Code: [Select]
manager.addTexture("jaguarsk.jpg", new Texture(this.getClass().getResource("RacerModels/Textures"), "jaguarsk.jpg")); but not by
Code: [Select]
background = new javax.swing.ImageIcon(this.getClass().getResource("RacerModels/Textures/CLOUDS1.JPG")).getImage();
The same error is true for manager.add(String, new Texture(this.getClass().getResourceAsStream(...)). What gives?
Title: Re: java.security.AccessControlException: access denied
Post by: paulscode on June 16, 2009, 02:29:47 am
manager.addTexture("jaguarsk.jpg", new Texture(this.getClass().getResource("RacerModels/Textures"), "jaguarsk.jpg"));
Probably just a typo, but I noticed you didn't include an actual filename:
Code: [Select]
manager.addTexture("jaguarsk.jpg", new Texture(this.getClass().getResourceAsStream("RacerModels/Textures/JAGUARSK.JPG"), "jaguarsk.jpg"));
Title: Re: java.security.AccessControlException: access denied
Post by: AGP on June 16, 2009, 02:37:46 am
It's neither a typo nor the only way I tried it. This:
Code: [Select]
manager.addTexture("jaguarsk.jpg", new Texture(this.getClass().getResourceAsStream("RacerModels/Textures/jaguarsk.jpg"))); doesn't work either (same security error).
Title: Re: java.security.AccessControlException: access denied
Post by: EgonOlsen on June 16, 2009, 07:23:16 am
Could be because the Swing-stuff is signed by SUN already (or trusted by default) and the methods that i'm using for loading a texture aren't. But i can't use any other to stay compatible with 1.1. You may try to load the images yourself and use the appropriate constructor that takes an image.
Title: Re: java.security.AccessControlException: access denied
Post by: AGP on June 16, 2009, 08:59:19 am
That did the trick. So simple! Still, I wish it had worked. What is the purpose of 1.1 compatibility, anyway?
Title: Re: java.security.AccessControlException: access denied
Post by: EgonOlsen on June 16, 2009, 09:40:14 am
That did the trick. So simple! Still, I wish it had worked. What is the purpose of 1.1 compatibility, anyway?
The purpose is...being compatible with 1.1... ;D Some users still rely on this.
Title: Re: java.security.AccessControlException: access denied
Post by: EgonOlsen on June 16, 2009, 09:41:21 am
Apart from that: If the files are in the jar, the applet should be able to access them no matter what.
Title: Re: java.security.AccessControlException: access denied
Post by: AGP on June 16, 2009, 10:15:26 am
But it wasn't able until I loaded them through ImageIcon. I can't explain it either. Anyway, as long as it works I am happy. I will post you a link of that racing game you liked soon. At this point I'm just working out the collision-detection. And here's a question: invisibility won't affect collision-detection, will it (I thought once that it did but I hope I'm wrong)?

Oh, and I was going to write that I think the latest version of Firefox changed the way it handles its cache, because all of a sudden I can run, change, recompile, repackage, and run again without it giving me headaches, which is making it much easier on me to test my stuff.
Title: Re: java.security.AccessControlException: access denied
Post by: EgonOlsen on June 16, 2009, 11:02:26 am
Visibility DOES affect collision detection. You can't collide with something that isn't visible/active. If this is a problem, set all colliders to visible before calling the collision methods and reset them afterwards where needed. I'm always doing it this way, because i usually use completely different meshes for collision than i use for the visuals.
Title: Re: java.security.AccessControlException: access denied
Post by: paulscode on June 16, 2009, 12:36:52 pm
Oh, I think I know what the problem might have been.  Rather than calling getResource[AsStream]() directly from Class, try using getClassLoader().getResource[AsStream]() instead:

Code: [Select]
manager.addTexture("jaguarsk.jpg", new Texture(this.getClass().getClassLoader().getResourceAsStream("RacerModels/Textures/jaguarsk.jpg"), "jaguarsk.jpg"));
Title: Re: java.security.AccessControlException: access denied
Post by: AGP on June 16, 2009, 06:17:15 pm
Thanks for the suggestion, paulscode. Is your way any faster?

And Egon, how fast is it to make something visible/invisble? Because as I understand, I'm going to have to make my object visible, test for collision, then make it invisible before I draw for every iteration. So is it just flipping an internal boolean or does work get done?
Title: Re: java.security.AccessControlException: access denied
Post by: EgonOlsen on June 16, 2009, 09:30:03 pm
Nope, it's just flipping a boolean. As said, i'm doing this constantly.
Title: Re: java.security.AccessControlException: access denied
Post by: AGP on June 16, 2009, 09:52:19 pm
Egon, I really hate showing my stuff to people because I really hate criticism, but here it goes: http://www.agpgames.com (http://www.agpgames.com)

All but the starship game is working to the point of showing it (if maybe not yet bragging!). Check out the racer. And by the way, I didn't do collision between the two cars yet. Thanks a whole lot both to you and to paulscode for the help with the opponent car. Street Fighter was a family joke between me, my wife my brother-in-law and his girlfriend (now wife). I'm still going to add blood and black eyes. All games are meant for an analog joystick, even if they work (badly) with the keyboard.
Title: Re: java.security.AccessControlException: access denied
Post by: EgonOlsen on June 16, 2009, 10:27:36 pm
My analog joystick (i've actually never really used it before) seems to suck. When plugged in and calibrated, the screen in Racer spins and doesn't stop. So i tried to play with the keyboard, which works pretty bad...as you've "promised".

I think Racer is a really good start. I like how it looks so far. Here are my suggestions on how to improve it IMHO:


As said, it's a good start. I think that improving the controls is the most important part because the best game concept fails if the controls suck. I'll try to find one of my semi-analog Competition Pro USB joysticks to see, if they work better....

Keep up the good work!

BTW: I can't load the street fighter applet...the link seems to be wrong.


Edit: Found and tried the Competition Pro...it's better than the other joystick but not much better than the keyboard. How am i supposed to accelerate? No matter what i do, i'm driving very very slow. This is on a P4M @ 2.2Ghz, i.e. a pretty old laptop of mine.


Title: Re: java.security.AccessControlException: access denied
Post by: paulscode on June 16, 2009, 10:38:48 pm
Thanks for the suggestion, paulscode. Is your way any faster?
I don't know, but it should eliminate the access control exception problem you were having when loading stuff that is compiled inside the JAR.
Title: Re: java.security.AccessControlException: access denied
Post by: AGP on June 16, 2009, 10:51:28 pm
Egon, I fixed the Street Fighter link. As for the joystick spinning the camera, no one in the lwjgl group seems to have a suggestion about it, so at the beginning of Racer I tell you to move the analog sticks before the car moves. I also find that if I press the accelerator button one or two seconds before the race the analog sticks default to zero value (as it always should).
Title: Re: java.security.AccessControlException: access denied
Post by: AGP on June 16, 2009, 10:53:27 pm
And the joystick uses a button for accelerating and another for braking. as opposed to up and down like the keyboard.
Title: Re: java.security.AccessControlException: access denied
Post by: AGP on June 17, 2009, 04:05:02 am
But to address your list of suggestions:

Thanks for your suggestions and do read what I wrote in response to your analog stick troubles.
Title: Re: java.security.AccessControlException: access denied
Post by: EgonOlsen on June 17, 2009, 07:18:09 am
I tried to wiggle around with the stick like the onscreen message says, but to no avail. I think it's the stick. I've never really used it, it may be broken.

About the double loading of textures...no, my method doesn't do this. The log messages that i got were, that a texture with the name <namehere> has been added twice to the manager preceded by a rescale message, which i got a bunch of before. So i assumed that they were loaded twice.

About the keyboard: It's possible to create good keyboard controls with the default event listeners. I don't think that LWJGL Keyboard class will work here, because it requires a Display to be created, which is only given in the context of the native OpenGL renderer.
I don't know how you do the keyboard stuff right now, but you may want to have a look at jPCT's KeyMapper-class in the util-package.
Title: Re: java.security.AccessControlException: access denied
Post by: AGP on June 17, 2009, 07:31:59 am
I will look into the KeyMapper, thanks.

For my other game, I told you about this already: ever since I switched the renderer from the old hardware method to the AWTGLCanvas, I keep getting ArrayIndexOutOfBoundsExceptions. No event threads either draw or change the models, and all the draw() calls are in a single game loop. So what are all the circumstances in which the World.draw(FrameBuffer) method might throw this right after a succesful call to World.renderScene(FrameBuffer)?
Title: Re: java.security.AccessControlException: access denied
Post by: EgonOlsen on June 17, 2009, 08:26:54 am
The only situation that i'm aware of where this could happen, is when some other thread fiddles around with an object while the draw()-call runs. I can't verify this problem in any other situation...i've never experienced it and i have quite a lot of test cases for AWTGLRenderer.
Do you have stack trace of this exception? Or, even better, a test case to reproduce it?
Title: Re: java.security.AccessControlException: access denied
Post by: AGP on June 17, 2009, 07:19:56 pm
I can send you the whole thing if you want to have a look. I find it really weird.
Title: Re: java.security.AccessControlException: access denied
Post by: EgonOlsen on June 17, 2009, 08:18:35 pm
If you could provide a version that i can use without much hassle, i'll give it a try.