Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

java.io.FilePermission: access denied?!

1,123 views
Skip to first unread message

Shicheng

unread,
Sep 16, 2000, 3:00:00 AM9/16/00
to
Hello there,
I have installed Java 2 (version 1.3) on my two PCs running
Win NT 4.0 and 2000. When testing a Java Help applet, I got the
java.security.AccessControlException error which I would like to obtian
advice from the list.

There are two java.policy files in these two dirs -
C:\jdk1.3\jre\lib\security and C:\Program Files\JavaSoft\JRE\1.3
\lib\security; and there is a .java.policy file in the dir -
C:\WINNT\Profiles\cmsst1; I have put the following lines in all these
three files:

grant codeBase "file:*" {
permission java.io.FilePermission "<<ALL
FILES>>", "read,write,execute,delete";
};

grant codeBase "file:*" {
permission java.security.AllPermission;
};

the problem is: after running the applet and pressing its
"Launch Help" button, I always get the same error (see details below)!?

Any advice on how to solve this problem will be helpful.

Thanks,

Shicheng

================the error message====================
C:\Temp\Java Distributed Objects\Source Code\Chpt_17
\Listings>appletviewer HelpApplet.html

java.security.AccessControlException: access denied
java.io.FilePermission C:\Temp\Java Distributed Objects\Source
Code\Chpt_17\Listings\HelpDemo\HelpDemo.hs read)
at java.security.AccessControlContext.checkPermission
(AccessControlContext.java:272)
at java.security.AccessController.checkPermission
(AccessController.java:399)
at java.lang.SecurityManager.checkPermission
(SecurityManager.java:545)
at java.lang.SecurityManager.checkRead(SecurityManager.java:890)
at java.io.File.isDirectory(File.java:564)
at sun.net.www.protocol.file.FileURLConnection.connect
(FileURLConnection.java:65)
at sun.net.www.protocol.file.FileURLConnection.initializeHeaders
(FileURL
Connection.java:82)
at sun.net.www.protocol.file.FileURLConnection.getHeaderField
(FileURLCon
nection.java:103)
at sun.net.www.URLConnection.getContentType
(URLConnection.java:109)
at com.sun.java.help.impl.XmlReader.createReader
(XmlReader.java:97)
at javax.help.HelpSet.parseInto(HelpSet.java:568)
at javax.help.HelpSet.<init>(HelpSet.java:129)
at HelpApplet$Launcher.actionPerformed(HelpApplet.java:38)
at javax.swing.AbstractButton.fireActionPerformed
(AbstractButton.java:1450)
at
javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
ctButton.java:1504)
at javax.swing.DefaultButtonModel.fireActionPerformed
(DefaultButtonModel
.java:378)
at javax.swing.DefaultButtonModel.setPressed
(DefaultButtonModel.java:250)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased
(BasicButtonL
istener.java:216)
at java.awt.Component.processMouseEvent(Component.java:3717)
at java.awt.Component.processEvent(Component.java:3546)
at java.awt.Container.processEvent(Container.java:1164)
at java.awt.Component.dispatchEventImpl(Component.java:2595)
at java.awt.Container.dispatchEventImpl(Container.java:1213)
at java.awt.Component.dispatchEvent(Component.java:2499)
at java.awt.LightweightDispatcher.retargetMouseEvent
(Container.java:2451)
at java.awt.LightweightDispatcher.processMouseEvent
(Container.java:2216)

at java.awt.LightweightDispatcher.dispatchEvent
(Container.java:2125)
at java.awt.Container.dispatchEventImpl(Container.java:1200)
at java.awt.Component.dispatchEvent(Component.java:2499)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
at java.awt.EventDispatchThread.pumpOneEvent
(EventDispatchThread.java:103)
at java.awt.EventDispatchThread.pumpEvents
(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)
Parsing failed for null
Got an IOException (access denied (java.io.FilePermission C:\Temp\Java
Distribut
ed Objects\Source Code\Chpt_17\Listings\HelpDemo\HelpDemo.hs read))
javax.help.HelpSetException: Could not parse
at javax.help.HelpSet.<init>(HelpSet.java:135)
at HelpApplet$Launcher.actionPerformed(HelpApplet.java:38)
at javax.swing.AbstractButton.fireActionPerformed
(AbstractButton.java:14
50)
at
javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
ctButton.java:1504)
at javax.swing.DefaultButtonModel.fireActionPerformed
(DefaultButtonModel
.java:378)
at javax.swing.DefaultButtonModel.setPressed
(DefaultButtonModel.java:250
)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased
(BasicButtonL
istener.java:216)
at java.awt.Component.processMouseEvent(Component.java:3717)
at java.awt.Component.processEvent(Component.java:3546)
at java.awt.Container.processEvent(Container.java:1164)
at java.awt.Component.dispatchEventImpl(Component.java:2595)
at java.awt.Container.dispatchEventImpl(Container.java:1213)
at java.awt.Component.dispatchEvent(Component.java:2499)
at java.awt.LightweightDispatcher.retargetMouseEvent
(Container.java:2451
)
at java.awt.LightweightDispatcher.processMouseEvent
(Container.java:2216)

at java.awt.LightweightDispatcher.dispatchEvent
(Container.java:2125)
at java.awt.Container.dispatchEventImpl(Container.java:1200)
at java.awt.Component.dispatchEvent(Component.java:2499)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
at java.awt.EventDispatchThread.pumpOneEvent
(EventDispatchThread.java:10
3)
at java.awt.EventDispatchThread.pumpEvents
(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)
==================================================================


=========================the applet===============================
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import javax.help.*;
import javax.swing.*;

public class HelpApplet extends JApplet
{
JButton theLauncher = new JButton("Launch Help");

public void init()
{
getContentPane().setLayout(new BorderLayout());
getContentPane().add(theLauncher,
BorderLayout.NORTH);
JLabel lbl = new JLabel(
"For help, click on the Launch Help button.");
Font f = new Font("Helvetica", Font.BOLD, 12);
lbl.setFont(f);
getContentPane().add(lbl, BorderLayout.SOUTH);
theLauncher.addActionListener(new Launcher());
}

public void fatalError(Exception ex)
{
ex.printStackTrace();
}

class Launcher implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{
try
{
URL url = new URL(getCodeBase(),
"HelpDemo/HelpDemo.hs");
HelpSet hs = new HelpSet(
getClass().getClassLoader(), url);
JHelp jh = new JHelp(hs);
jh.setVisible(true);
getContentPane().add(jh, BorderLayout.CENTER);
invalidate();
validate();
}
catch (Exception ex) { fatalError(ex); }
}
}
}
========================================================


============================HelpDemo.hs=================

<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?>
<helpset>
<title>JavaHelp Demo</title>
<maps>
<homeID>top</homeID>
<mapref location = "Map.jhm"/>
</maps>
<view>
<name>TOC</name>
<label>Table Of Contents</label>
<type>javax.help.TOCView</type>
<data>HelpDemoTOC.xml</data>
</view>
</helpset>
=======================================================


======================Map.jhm===========
toplevelfolder=images/toplevel.gif

top=Title.html
intro=Intro.html
section0101=Section0101.html
section0102=Section0102.html
section0201=Section0201.html
section0202=Section0202.html
=============================================

===================HelpDemoTOC.xml===========
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?>
<toc>
<tocitem id=top>JavaHelp Demo

<tocitem id=intro>Introduction</tocitem>

<tocitem>Chapter #1
<tocitem id=section0101>Section #1</tocitem>
<tocitem id=section0102>Section #2</tocitem>
</tocitem>

<tocitem>Chapter #2
<tocitem id=section0201>Section #1</tocitem>
<tocitem id=section0202>Section #2</tocitem>
</tocitem>

</tocitem>
</toc>
==============================================


Sent via Deja.com http://www.deja.com/
Before you buy.

ss...@my-deja.com

unread,
Sep 27, 2000, 3:00:00 AM9/27/00
to
Hi,

the entry should be:

grant {
permission java.security.AllPermission;
};

Bye Stefan

In article <8pvvah$or6$1...@nnrp1.deja.com>,

Shicheng

unread,
Sep 29, 2000, 3:00:00 AM9/29/00
to
Hi Stefan,
Thanks for your advice which works!

Shicheng :-)

In article <8qt0js$ump$1...@nnrp1.deja.com>,

Alex Mayzlin

unread,
Oct 19, 2000, 3:00:00 AM10/19/00
to
Hi Shicheng!!! I was just wondering what browser this fix works in. For me
it works only in IE. If you also have this working in Netscape, could you
please tell me how you did it?

Thank you
Alex

0 new messages