aspose file tools*
The moose likes Applets and the fly likes java.security.AccessControlException: access denied (java.net.SocketPermission ftp.powweb.com Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "java.security.AccessControlException: access denied (java.net.SocketPermission ftp.powweb.com" Watch "java.security.AccessControlException: access denied (java.net.SocketPermission ftp.powweb.com" New topic
Author

java.security.AccessControlException: access denied (java.net.SocketPermission ftp.powweb.com

Sara Al
Greenhorn

Joined: Oct 27, 2011
Posts: 2
Hi,

I'm creating a Java Applet that uploads a file on a local machine into an FTP server. I'm using Apache FTP Client to connect and upload. The applet works fine when I run it from netbeans but when I embed in in html and run it in the browser it gives me the following exception :

java.security.AccessControlException: access denied (java.net.SocketPermission ftp.powweb.com resolve)
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.checkConnect(Unknown Source)
at sun.plugin2.applet.Applet2SecurityManager.checkConnect(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at java.net.InetAddress.getByName(Unknown Source)
at java.net.InetSocketAddress.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at org.apache.commons.net.DefaultSocketFactory.createSocket(DefaultSocketFactory.java:52)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:161)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:249)
at Main.loginAndConnect(Main.java:83)
at Main$1.actionPerformed(Main.java:48)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "Thread-16" java.lang.NullPointerException
at org.apache.commons.net.SocketClient.getLocalAddress(SocketClient.java:441)
at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:447)
at org.apache.commons.net.ftp.FTPClient.__storeFileStream(FTPClient.java:396)
at org.apache.commons.net.ftp.FTPClient.storeFileStream(FTPClient.java:1391)
at FileUploader.run(FileUploader.java:60)

I also had another exception which was a file I/O exception but I solved it by signing the applet using the following commands:

keytool -genkey -keystore pKeyStore -alias p5geek
keytool -selfcert -keystore pKeyStore -alias p5geek
jarsigner -keystore pKeyStore UploadApplet.jar p5geek

I thought this would solve the socket exception that I have now but it didn't. Can anyone help me in this please.

Thank you very much.
Sara





sachin potu
Greenhorn

Joined: Oct 22, 2011
Posts: 21
are you directly reading file from the Applet -->> this will work but you need to change java security policy file
if you have an upload button in your applet , then it should work without any problem
Sara Al
Greenhorn

Joined: Oct 27, 2011
Posts: 2
The applet has an upload button that opens a JFileChoser, once the file is selected, I try to connect to the server. I don't know how to change the policy file or what to include in it, I'm new to this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.security.AccessControlException: access denied (java.net.SocketPermission ftp.powweb.com