Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-28-2008, 06:37 AM
Member
 
Join Date: May 2008
Posts: 26
Master Zero is on a distinguished road
Socket applet programming error?
Hello,

I have an applet which when run from eclipse works fine, but on my web server gives me an error. I am not sure what the error means, but could it be permission relate? If so then how do I set the proper permissions? Here’s the error, if my class code is needed, then I will provide it as well.

Code:
Java Plug-in 1.6.0_03 Using JRE version 1.6.0_03 Java HotSpot(TM) Client VM User home directory = C:\Documents and Settings\Admin ---------------------------------------------------- c: clear console window f: finalize objects on finalization queue g: garbage collect h: display this help message l: dump classloader list m: print memory usage o: trigger logging p: reload proxy configuration q: hide console r: reload policy configuration s: dump system and deployment properties t: dump thread list v: dump thread stack x: clear classloader cache 0-5: set trace level to <n> ---------------------------------------------------- Exception in thread "AWT-EventQueue-2" java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:4000 connect,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.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.<init>(Unknown Source) at java.net.Socket.<init>(Unknown Source) at ChatClient.actionPerformed(ChatClient.java:74) 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.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)
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-28-2008, 06:47 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,538
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
I hope you don't have access privileges through the service. Any username password are not to be set. Is there such any?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-28-2008, 06:57 AM
Member
 
Join Date: May 2008
Posts: 26
Master Zero is on a distinguished road
Hi,

The server is a java application (well jar file) listening for a client to connect. It works well from eclipse (the applet), but not on my web server. As far as I know, there aren’t any username and passwords involved.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-28-2008, 07:17 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,538
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
I think it is,

Code:
access denied (java.net.SocketPermission 127.0.0.1:4000 connect,resolve)
Are you sure that through that port you can listen?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-28-2008, 10:30 PM
Member
 
Join Date: May 2008
Posts: 26
Master Zero is on a distinguished road
Yes I am positive because when the client runs locally, it connects fine to the server. Here is proof of it running locally, the link below is a screenshot of it:

Code:
img294.imageshack.us/img294/1895/clipimage002wl1.jpg
It’s only from the web server that it can not seem to connect from. Here is the client code:

Code:
import java.io.*; import java.awt.*; import java.net.*; import javax.swing.*; import javax.swing.text.*; import java.awt.event.*; import java.applet.Applet; public class ChatClient extends Applet implements ActionListener { /** * */ private static final long serialVersionUID = 1L; // Variables TextField msg; TextArea room; Style color; StyledDocument doc; Panel cPanel; JLabel lblIP; JTextField IP; JButton connect; PrintStream os; DataInputStream is; Socket clientSocket; public void init() { this.setLayout(new BorderLayout()); msg = new TextField(); room = new TextArea("", 5, 50, TextArea.SCROLLBARS_VERTICAL_ONLY); cPanel = new Panel(); lblIP = new JLabel("IP Address:"); IP = new JTextField("127.0.0.1"); IP.setHorizontalAlignment(JTextField.CENTER); connect = new JButton("Connect"); connect.addActionListener(this); cPanel.setLayout(new BorderLayout()); cPanel.add("Center", IP); cPanel.add("West", lblIP); cPanel.add("East", connect); this.add("South", msg); this.add("Center", room); this.add("North", cPanel); } // Sends the text public void sendText(String message) { os.println(message); os.flush(); } // AWT event handler @SuppressWarnings("deprecation") public boolean keyDown(Event evt, int key) { //System.out.println(key); if (key == 10) { room.append(msg.getText() + "\n"); this.sendText(msg.getText()); msg.setText(""); //return true; // ignores the key } return super.keyDown(evt, key); } public void actionPerformed(ActionEvent e) { if (e.toString().split(",")[1].substring(4).equals("Connect")) { try { this.clientSocket = new Socket(IP.getText(), 4000); os = new PrintStream(this.clientSocket.getOutputStream()); is = new DataInputStream(this.clientSocket.getInputStream()); room.append("Connection successful...\n"); Listen listen = new Listen(); new Thread(listen).start(); } catch (UnknownHostException e1) { // TODO Auto-generated catch block e1.printStackTrace(); room.append(e1.getMessage()); System.exit(0); } catch (IOException e2) { // TODO Auto-generated catch block e2.printStackTrace(); room.append(e2.getMessage()); System.exit(0); } } } // This class will be used to implement threading public class Listen implements Runnable { @SuppressWarnings("deprecation") public void run(){ try { room.append("Server --> " + is.readLine() + "\n"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); room.append(e.getMessage()); System.exit(0); } run(); } } }
I am also behind a route, do you think that can be the issue?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Socket programming - accepting files ravian Networking 2 11-29-2007 11:40 AM
Socket Programming (Client) JavaForums Java Blogs 0 11-26-2007 05:00 PM
Socket Programming (Server) JavaForums Java Blogs 0 11-26-2007 05:00 PM
Socket programming - port issues ravian Networking 2 11-07-2007 11:24 AM
Programming Socket Question paul Networking 1 07-30-2007 08:26 PM


All times are GMT +3. The time now is 11:14 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org