Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
12.5k views
in Java FTP by
Does it work? I have this bit of code here which works fine in an application, but gives an runtime error when I try it in an applet.

import java.awt.*;
import java.applet.*;
import com.enterprisedt.net.ftp.*;

public class mUpload extends Applet
{
   private static String msg;
   
   public void init()
   {
      String server = new String("localhost");
      String user = new String("test");
      String passwd = new String("testtest");
      FTPClient ftp = null;
      msg = "Default";
      
      try
      {
         ftp = new FTPClient(server);
         ftp.login(user, passwd);
         ftp.put("C:\\me.rtf", "you.rtf");
      }
      catch (Exception e)
      {
         msg = e.toString();
      }
   }

   public void paint(Graphics g)
   {
      g.drawString(msg, 50, 60);
   }
}


Here's the error:
java.lang.ExceptionInInitializerError
        at com.enterprisedt.net.ftp.FTPClient.<init>(FTPClient.java:203)
        at com.enterprisedt.net.ftp.FTPClient.<init>(FTPClient.java:348)
        at com.enterprisedt.net.ftp.FTPClient.<init>(FTPClient.java:319)
        at mUpload.init(mUpload.java:28)
        at sun.applet.AppletPanel.run(AppletPanel.java:353)
        at java.lang.Thread.run(Thread.java:534)
Caused by: java.security.AccessControlException: access denied (java.util.PropertyPermission edtftp.log.level read)
        at java.security.AccessControlContext.checkPermission(AccessControlContext.java:269)
        at java.security.AccessController.checkPermission(AccessController.java:401)
        at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
        at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1276)
        at java.lang.System.getProperty(System.java:612)
        at com.enterprisedt.util.debug.Logger.<clinit>(Logger.java:128)
        ... 6 more


Any ideas?

15 Answers

0 votes
by
Hi,

i'm also using edtFTP in an applet, but with version 1.4.6 it still doensn't work. When running the applet i get the folowing error:
java.security.AccessControlException: access denied (java.net.SocketPermission spirit.jeugdkerken.nl 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 java.net.InetAddress.getAllByName0(Unknown Source)

at java.net.InetAddress.getAllByName0(Unknown Source)

at java.net.InetAddress.getAllByName(Unknown Source)

at java.net.InetAddress.getByName(Unknown Source)

at com.enterprisedt.net.ftp.FTPClient.<init>(FTPClient.java:390)

at com.enterprisedt.net.ftp.FTPClient.<init>(FTPClient.java:361)

at platform.FTPThread.executeTransfers(FTPApplet.java:237)

at platform.FTPThread.run(FTPApplet.java:199)

Using JBuilder to run the applet it works correctly and connects, but directly opening the applet page from hd, or from a local server or from the internet, it gives the error above.

with kind greetings,

Michel
0 votes
by (162k points)
An applet (unless signed) can only connect back to the host it is downloaded from.

Hi,

i'm also using edtFTP in an applet, but with version 1.4.6 it still doensn't work. When running the applet i get the folowing error:
java.security.AccessControlException: access denied (java.net.SocketPermission spirit.jeugdkerken.nl resolve)
0 votes
by
Hi,

i'm also using edtFTP in an applet, but with version 1.4.6 it still doensn't work. When running the applet i get the folowing error:
java.security.AccessControlException: access denied (java.net.SocketPermission spirit.jeugdkerken.nl 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 java.net.InetAddress.getAllByName0(Unknown Source)

at java.net.InetAddress.getAllByName0(Unknown Source)

at java.net.InetAddress.getAllByName(Unknown Source)

at java.net.InetAddress.getByName(Unknown Source)

at com.enterprisedt.net.ftp.FTPClient.<init>(FTPClient.java:390)

at com.enterprisedt.net.ftp.FTPClient.<init>(FTPClient.java:361)

at platform.FTPThread.executeTransfers(FTPApplet.java:237)

at platform.FTPThread.run(FTPApplet.java:199)

Using JBuilder to run the applet it works correctly and connects, but directly opening the applet page from hd, or from a local server or from the internet, it gives the error above.

with kind greetings,

Michel
0 votes
by (162k points)
Read up a little on applet security and network operations.
0 votes
by (162k points)
Please read the thread:

"An applet (unless signed) can only connect back to the host it is downloaded from".

Hi,

i'm also using edtFTP in an applet, but with version 1.4.6 it still doensn't work. When running the applet i get the folowing error:
java.security.AccessControlException: access denied (java.net.SocketPermission spirit.jeugdkerken.nl resolve)

Categories

...