Sara Al

Greenhorn
+ Follow
since Oct 27, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sara Al

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.
12 years ago
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





12 years ago