Author Topic: java.security.AccessControlException: access denied  (Read 6016 times)

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
java.security.AccessControlException: access denied
« 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?

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: java.security.AccessControlException: access denied
« Reply #1 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"));

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: java.security.AccessControlException: access denied
« Reply #2 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).

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: java.security.AccessControlException: access denied
« Reply #3 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.

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: java.security.AccessControlException: access denied
« Reply #4 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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: java.security.AccessControlException: access denied
« Reply #5 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: java.security.AccessControlException: access denied
« Reply #6 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.

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: java.security.AccessControlException: access denied
« Reply #7 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.
« Last Edit: June 16, 2009, 10:34:14 am by AGP »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: java.security.AccessControlException: access denied
« Reply #8 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.

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: java.security.AccessControlException: access denied
« Reply #9 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"));

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: java.security.AccessControlException: access denied
« Reply #10 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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: java.security.AccessControlException: access denied
« Reply #11 on: June 16, 2009, 09:30:03 pm »
Nope, it's just flipping a boolean. As said, i'm doing this constantly.

Offline AGP

  • quad
  • ******
  • Posts: 1518
    • View Profile
Re: java.security.AccessControlException: access denied
« Reply #12 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

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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: java.security.AccessControlException: access denied
« Reply #13 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:

  • Scale your textures to power of 2. jPCT does this for you while loading, but it slows down the loading process
  • Get rid of the double loading of textures. For some reason, you seem to load them twice
  • Fix the transparency. Remember that even the software renderer can do additive blending, which should look nice on the lights
  • Improve the keyboards controls. I have to hit UP multiple times to accelerate, which is very annoying
  • Fix the steering. It seems to rotate the car even when standing still
  • Somehow, the size of the car doesn't really match the rest of the scene. The car is hardly higher than the curb and maybe half as high as a door. That looks pretty strange. Like in some AAA commercial shooter games, where your hero barely reaches the doorknob... ;D
  • Add support for the hardware renderer. You are loading LWJGL anyway, so why not use it to fullest if possible!? Albeit i like the look of the software renderer...
  • Consider to use raft's MipMapping extension when using the software renderer (if the applet's memory restrictions allow for that)

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.


« Last Edit: June 16, 2009, 10:39:10 pm by EgonOlsen »

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: java.security.AccessControlException: access denied
« Reply #14 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.