aspose file tools*
The moose likes Applets and the fly likes Security Exception in JApplet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Security Exception in JApplet" Watch "Security Exception in JApplet" New topic
Author

Security Exception in JApplet

Surya Kant
Ranch Hand

Joined: Mar 29, 2005
Posts: 104
Hi All,
I have one JApplet in which i am adding swing component to it.While doing this operation it is throwing following exception

java.security.AccessControlException: access denied (java.lang.RuntimePermission createClassLoader)

PLease let me know if you people know the solution..

Regards,
Surya
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41489
    
  53
Simply using Swing components should not result in this message; are you doing anything with class loaders? Post the full stack trace as well.

The generic way of getting around security exceptions in applets is to sign the apple tor to alter the local security policy. Both methods are described here. But, as stated above, that should not be necessary for using Swing.
[ April 10, 2007: Message edited by: Ulf Dittmer ]

Ping & DNS - my free Android networking tools app
Surya Kant
Ranch Hand

Joined: Mar 29, 2005
Posts: 104
her is the full stack trace..Let me know if something can be deciphered from this trace
java.security.AccessControlException: access denied (java.lang.RuntimePermission createClassLoader)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkCreateClassLoader(Unknown Source)
at java.lang.ClassLoader.<init>(Unknown Source)
at java.security.SecureClassLoader.<init>(Unknown Source)
at java.net.URLClassLoader.<init>(Unknown Source)
at com.huawei.iweb.report.engine.lite.remote.RemoteReportEngine.createConditionClassLoader(RemoteReportEngine.java:887)
at com.huawei.iweb.report.engine.lite.remote.RemoteReportEngine.getConditionInfo(RemoteReportEngine.java:385)
at com.ConditionUI.init(ConditionUI.java:52)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Regards,
Surya
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41489
    
  53
Ah, you're using a 3rd-party library that does something with classloaders. In that case, there's no way around using one of the two ways described in the link I posted.
Surya Kant
Ranch Hand

Joined: Mar 29, 2005
Posts: 104
Hi,
I have tried both the options.I m using signed jars and i changed the policy file also.But still it is giving exception.
What else could be the problem?

Regards,
Surya
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41489
    
  53
What else could be the problem?


That is the problem. Are you certain that the certificate is accepted, and that the policy file you changed is actually used? How did you test that?
Surya Kant
Ranch Hand

Joined: Mar 29, 2005
Posts: 104
Let me tell you what exactyl i am trying to do..
I want to develop one webapplication in which i have one servlet & applet.
1.Through jsp page i get some information from user
2.After that i redirect control to applet
3.Applet uses user given information to prepare swing UI.While getting this swing UI it uses soem third party libaray class which is trying to load some class (As you have seen in statck strace)

I am using eclise 3.2 to develop this application.
In tomcat's jvm settings i am adding this entry
-Djava.security.policy="C:/Program Files/Java/j2re1.4.2_04/lib/security/java.policy"
which will point to my policy file.

Do let me know if you need any other information other than this..
Surya Kant
Ranch Hand

Joined: Mar 29, 2005
Posts: 104
hi..
That problem solved.But facing one more problem..i got rid of that problme by signing applet itself :-)

Now one more problme is coming..
java.security.AccessControlException: access denied (java.util.PropertyPermission * read,write)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPropertiesAccess(Unknown Source)
at java.beans.Introspector.setBeanInfoSearchPath(Unknown Source)
at com.huawei.iweb.ui.util.ElementFactory.fillElementModel(ElementFactory.java:495)
at com.huawei.iweb.ui.util.ElementFactory.buildPanel(ElementFactory.java:392)
at com.huawei.iweb.ui.util.ElementFactory.createGroup(ElementFactory.java:265)
at com.huawei.iweb.report.condition.impl.DefaultExtConditionUi.getUi(DefaultExtConditionUi.java:87)
at com.huawei.iweb.report.condition.ReportConditionUiApplet.arrangeUi(ReportConditionUiApplet.java:362)
at com.huawei.iweb.report.condition.ReportConditionUiApplet.init(ReportConditionUiApplet.java:280)
at com.huawei.iweb.report.engine.lite.remote.RemoteReportEngine.getConditionUi(RemoteReportEngine.java:360)
at com.ConditionUI.init(ConditionUI.java:54)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


Regards,
Surya
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41489
    
  53
That's the same problem. You need to sign all the jar files that make up the applet.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Security Exception in JApplet