AccessControlException

K

Ken Kast

The following is a snippet from a method in an applet RSSTree:
private Document getOPMLFile(String OPMLFileName) {

Document OPMLFile = null;

try {

URL u = new URL(getCodeBase(), OPMLFileName);

try {

BufferedReader br = new BufferedReader(new
InputStreamReader(u.openStream()));

if (br != null) {

try {

Builder parser = new Builder();

OPMLFile = parser.build(br);

}

..
..
..

This method is called out of RSSTree.start(). Document & Builder are
classes in the open source XML processor com.nu.xom. I get the following
error when parser.build(br) is executed:

java.lang.ExceptionInInitializerError
at RSSTree.getOPMLFile(RSSTree.java:63)
at RSSTree.start(RSSTree.java:31)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Caused by: java.security.AccessControlException: access denied
(java.util.PropertyPermission
org.apache.xerces.xni.parser.XMLParserConfiguration 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.System.setProperty(Unknown Source)
at nu.xom.Builder.<clinit>(Unknown Source)

If I replace the bad line with a loop to read the the stream myself and
write out the lines, I get the XML I expect.

Without seeing the source for XOM can someone give me an idea as to why I
have an access problem when going through XOM but don't when the applet
reads directly?

Thanks.

Ken
 
C

Chris Smith

Ken said:
This method is called out of RSSTree.start(). Document & Builder are
classes in the open source XML processor com.nu.xom. I get the following
error when parser.build(br) is executed:

java.lang.ExceptionInInitializerError
[...]

Caused by: java.security.AccessControlException: access denied
Without seeing the source for XOM can someone give me an idea as to why I
have an access problem when going through XOM but don't when the applet
reads directly?

Sure. When XOM initializes itself, it tries to set a system property.
That's not allowed in an applet context. You might check documentation
for XOM or ask their support or mailing lists how to prevent XOM from
trying to set that system property. Otherwise, that library isn't
usable from a non-privileged applet, or any other code running under a
restricted SecurityManager.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top