Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Java Applet exception when accessing an FTP server

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Java Applet exception when accessing an FTP server

    Hi,

    I'm creating an applet for my website to enable users to upload files to an FTP server. When I run the applet in the browser I get 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(Unk nown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkConnect(Unknown Source)
    at sun.plugin2.applet.Applet2SecurityManager.checkCon nect(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.create Socket(DefaultSocketFactory.java:52)
    at org.apache.commons.net.SocketClient.connect(Socket Client.java:161)
    at org.apache.commons.net.SocketClient.connect(Socket Client.java:249)
    at Main.loginAndConnect(Main.java:83)
    at Main$1.actionPerformed(Main.java:48)
    at javax.swing.AbstractButton.fireActionPerformed(Unk nown 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.mouseRe leased(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(U nknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn 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.doIntersectio nPrivilege(Unknown Source)
    at java.security.AccessControlContext$1.doIntersectio nPrivilege(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.doIntersectio nPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(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.getLocalAddres s(SocketClient.java:441)
    at org.apache.commons.net.ftp.FTPClient._openDataConn ection_(FTPClient.java:447)
    at org.apache.commons.net.ftp.FTPClient.__storeFileSt ream(FTPClient.java:396)
    at org.apache.commons.net.ftp.FTPClient.storeFileStre am(FTPClient.java:1391)
    at FileUploader.run(FileUploader.java:60)

    Im using Apache FTP client and when The code reaches the connect method the exception occurs. Can anyone help me in this please


    Thanks

    Sara


  2. #2
    Member
    Join Date
    Oct 2011
    Posts
    50
    My Mood
    Fine
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: Java Applet exception when accessing an FTP server

    It's a security issues. The current security policy does not allow you to connect on specified host/port, so you will need to change the security policy. More about how to do this and the topic here (2nd half of the page): Java RMI Tutorial.

    application context
    Last edited by daniel.j2ee; December 13th, 2011 at 05:01 PM.

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Java Applet exception when accessing an FTP server

    Sign the applet. See the following:
    What Applets Can and Cannot Do (The Java™ Tutorials > Deployment > Java Applets)

Similar Threads

  1. Applet-Server Communication
    By bgroenks96 in forum Java Applets
    Replies: 7
    Last Post: September 12th, 2011, 08:48 PM
  2. Accessing an external JAR file using Applet
    By rameshiit19 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: July 28th, 2011, 12:51 AM
  3. Applet throw ClassNotFound exception when one of the file is recompiled
    By philwei in forum What's Wrong With My Code?
    Replies: 21
    Last Post: July 12th, 2011, 01:21 PM
  4. Created simple game applet but wanting it to access a DSN on the server
    By hirsty in forum What's Wrong With My Code?
    Replies: 7
    Last Post: April 21st, 2011, 03:11 AM
  5. applet + swing + arraylist = exception??
    By wolfgar in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 1st, 2010, 11:38 PM