Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Applet accesscontrolexception in 1.6.0.24

 
rajeev yadav
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone,

I am getting accesscontrolexception with applet in 1.6..0.24. Earlier it used to work fine. My applet is signed.

Thanks,
Rajeev
 
Paul Clapham
Sheriff
Posts: 21567
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you considered investigating the problem? I'm assuming you didn't post that just for our information, but because you considered it to be a problem and wanted to do something about it. If that's the case, then you should investigate.

Note that your problem statement doesn't contain enough information for anybody to investigate your problem. That only leaves you as a resource. Of course you could always post information here. Such as error messages, stack traces, that sort of thing.
 
rajeev yadav
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your quick response.

My applet works with java 1.6.0.23 or earlier version but gives below error when java 1.6.0.24 is used. Here it tries to call showfilechooser method and throws accesscontrolexcpetion. below is the complete stack trace.

Exception in thread "AWT-EventQueue-2" java.security.AccessControlException: access denied (java.io.FilePermission C:\Users\rajeev\AppData\Roaming\Microsoft\Windows\Recent read)
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.checkRead(Unknown Source)
at java.io.File.exists(Unknown Source)
at java.io.Win32FileSystem.canonicalize(Unknown Source)
at java.io.File.getCanonicalPath(Unknown Source)
at sun.awt.shell.Win32ShellFolderManager2.createShellFolder(Unknown Source)
at sun.awt.shell.Win32ShellFolderManager2.getRecent(Unknown Source)
at sun.awt.shell.Win32ShellFolderManager2.get(Unknown Source)
at sun.awt.shell.ShellFolder.get(Unknown Source)
at sun.swing.WindowsPlacesBar.<init>(Unknown Source)
at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.updateUseShellFolder(Unknown Source)
at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installComponents(Unknown Source)
at javax.swing.plaf.basic.BasicFileChooserUI.installUI(Unknown Source)
at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installUI(Unknown Source)
at javax.swing.JComponent.setUI(Unknown Source)
at javax.swing.JFileChooser.updateUI(Unknown Source)
at javax.swing.JFileChooser.setup(Unknown Source)
at javax.swing.JFileChooser.<init>(Unknown Source)
at javax.swing.JFileChooser.<init>(Unknown Source)
at com.dell.ren.wicket.panel.upload.applet.FileDropApplet.getFileChooser(FileDropApplet.java:953)
at com.dell.ren.wicket.panel.upload.applet.FileDropApplet$11.run(FileDropApplet.java:913)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
 
rajeev yadav
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please help if it is a bug in this java version or some added security feature that is causing the issue and also please suggest workaround...
 
Yuri Filimonov
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have encountered the same problem. You should use privileged code, see HowCanAnAppletReadFilesOnTheLocalFileSystem
 
rajeev yadav
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your post. I saw the link but i m not sure where do i need to write this priviledged code. I am call showfilechooser from javascript.
 
Yuri Filimonov
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you will post fragment of com.dell.ren.wicket.panel.upload.applet.FileDropApplet source where getFileChooser method called (method run of anonymous inner class), I could point out what should be changed.
 
rajeev yadav
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
below is javascript code:

function showAppletFilePicker() {
var applet = document.uploadApplet;
applet.showFileChooser();
}
 
Yuri Filimonov
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need change and recompile the applet java source code. If you haven't got it you should probably ask the applet developer for support.
 
rajeev yadav
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Below is the java fragment from applet class.

// Else, register a handler on the label to popup the chooser
// when a user clicks the left button on the applet image.
label.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1) {
showFileChooser();
}
}
});


===================================showfilechooser method=====================

/**
* Show the JFileChooser which can be used to upload files/dirs.
*/
public void showFileChooser() {

if( !_isUploadAreaEnabled) {
return;
}

final Container container = this.getContentPane();

// Be sure to create, popup, and process the file chooser on another
// thread, since this callback is being made from the main Swing thread.
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// Get the lazy-initted file chooser.
JFileChooser fileChooser = getFileChooser();

// Set the current directory to the last directory selected
if (_lastFileChooserDir != null) {
fileChooser.setCurrentDirectory(_lastFileChooserDir);
}

// Allow directories if we're configured to process them...
if (_processDirs) {
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
} else {
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
}

int returnVal = fileChooser.showDialog(container, _fileChooserTitle);

// Record the current directory so we can set it the next time
// the browser is popped up.
_lastFileChooserDir = fileChooser.getCurrentDirectory();

// Process the action
if (returnVal == JFileChooser.APPROVE_OPTION) {
final File file = fileChooser.getSelectedFile();

// Fake a callback to the Observable used to monitor "files dropped",
// which will kickoff an upload operation back into this object.
_dropListener.getFilesDroppedObservable().notifyObservers(new File[]{file});
}
}
});
}

 
rajeev yadav
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In above code it errors out on line
// Get the lazy-initted file chooser.
JFileChooser fileChooser = getFileChooser();

Please help on how to change the code for priviledged access.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
rajeev yadav wrote:Please help on how to change the code for priviledged access.

After having studied the page Yuri linked to, how do you think it should look? Give it a shot, and we'll chime in if you encounter problems.
 
Yuri Filimonov
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After the lines:

should be inserted:

and after the line (i have corrected here, before closing '}'):

should be inserted:

And add required imports in the beginning of the source file.
It is ugly but it should work.
I think there is another place (or places) in the code where the selected file is actually read. It should be changed the same way.
 
rajeev yadav
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Yuri..

I tried above mentioned changed with no luck... still same error..
 
Yuri Filimonov
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Didn't you forget to sign recompiled applet jar? Is stack trace the same? I need some information to see what goes wrong.
 
rajeev yadav
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we are compiling applet jar everytime and also signing it after compiling it.. Shortly, I will let you know the errot that we are getting
 
rajeev yadav
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Below are errors that i can see in console:

Exception in thread "AWT-EventQueue-2" java.security.AccessControlException: access denied (java.io.FilePermission C:\Users\rajeev_yadav\AppData\Roaming\Microsoft\Windows\Recent read)
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.checkRead(Unknown Source)
at java.io.File.exists(Unknown Source)
at java.io.Win32FileSystem.canonicalize(Unknown Source)
at java.io.File.getCanonicalPath(Unknown Source)
at sun.awt.shell.Win32ShellFolderManager2.createShellFolder(Unknown Source)
at sun.awt.shell.Win32ShellFolderManager2.getRecent(Unknown Source)
at sun.awt.shell.Win32ShellFolderManager2.get(Unknown Source)
at sun.awt.shell.ShellFolder.get(Unknown Source)
at sun.swing.WindowsPlacesBar.<init>(Unknown Source)
at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.updateUseShellFolder(Unknown Source)
at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installComponents(Unknown Source)
at javax.swing.plaf.basic.BasicFileChooserUI.installUI(Unknown Source)
at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installUI(Unknown Source)
at javax.swing.JComponent.setUI(Unknown Source)
at javax.swing.JFileChooser.updateUI(Unknown Source)
at javax.swing.JFileChooser.setup(Unknown Source)
at javax.swing.JFileChooser.<init>(Unknown Source)
at javax.swing.JFileChooser.<init>(Unknown Source)
at com.dell.ren.wicket.panel.upload.applet.FileDropApplet.getFileChooser(FileDropApplet.java:953)
at com.dell.ren.wicket.panel.upload.applet.FileDropApplet$11.run(FileDropApplet.java:913)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown
 
Yuri Filimonov
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I can see the stack trace is the same. It means old version of applet jar is executed. New applet should have another run method frame in stack trace on the top of the line
at com.dell.ren.wicket.panel.upload.applet.FileDropApplet$11.run(FileDropApplet.java:913)
Try to clear the browser cache and restart browser program. And check applet jar file size downloaded from the web server to exclude dumb mistakes.
 
rajeev yadav
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Yuri,

It was my miss. I did not deploy applet jar with code changes. After deploying, it is working fine. Many Many thanks to you.. You are champ



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic