File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes bizar JFileChooser error after connection refused to localhost Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "bizar JFileChooser error after connection refused to localhost" Watch "bizar JFileChooser error after connection refused to localhost" New topic
Author

bizar JFileChooser error after connection refused to localhost

Pander Musubi
Greenhorn

Joined: May 15, 2003
Posts: 16
Hi all,
I have a dialog for selecting a file or a remote server, it has a JFileChooser which displays the contents of directory data which is in the current directory.
I was testing my error handling for when I don't have an RMI registry running. Then it displays a message box with an error and should create new JFileChooser but cannot do this anymore. Even reusing the existing JFileChooser doesn't work anymore!
Note that is has problems with my home dir / desktop dir althoug i'm not running it from that dir. Is this a Java bug?
Exception in thread "main" java.security.AccessControlException: access denied (
java.io.FilePermission C:\Documents and Settings\XXXXX\Desktop read)
at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:270)
at java.security.AccessController.checkPermission(AccessController.java:
401)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:542)
at java.lang.SecurityManager.checkRead(SecurityManager.java:887)
at java.io.File.exists(File.java:677)
at sun.awt.shell.ShellFolder.exists(ShellFolder.java:257)
at javax.swing.filechooser.FileSystemView.getSystemDisplayName(FileSyste
mView.java:140)
at javax.swing.plaf.basic.BasicFileChooserUI$BasicFileView.getName(Basic
FileChooserUI.java:1023)
at javax.swing.plaf.metal.MetalFileChooserUI.installComponents(MetalFile
ChooserUI.java:216)
at javax.swing.plaf.basic.BasicFileChooserUI.installUI(BasicFileChooserU
I.java:130)
at javax.swing.plaf.metal.MetalFileChooserUI.installUI(MetalFileChooserU
I.java:152)
at javax.swing.JComponent.setUI(JComponent.java:449)
at javax.swing.JFileChooser.updateUI(JFileChooser.java:1700)
at javax.swing.JFileChooser.setup(JFileChooser.java:345)
at javax.swing.JFileChooser.<init>(JFileChooser.java:320)
at javax.swing.JFileChooser.<init>(JFileChooser.java:303)
at suncertify.client.Gui.selectDatabaseDialog(Gui.java:271)
at suncertify.client.Gui.<init>(Gui.java:38)
at suncertify.client.Gui.main(Gui.java:366)
Pander Musubi
Greenhorn

Joined: May 15, 2003
Posts: 16
I'll think I'l just get rid of the JFileChooser all together. It's not in the requirements. Just pass the file name as args[0] and have the user choose between that and remote server.
Makes it more safe so user cannot go browsing around the entire system with the file chooser.
Are there more people that also submit command line args to the client appl? like optionally default RMI hostname and optionally default port?
P.
Bill Robertson
Ranch Hand

Joined: Mar 21, 2003
Posts: 234
I have a dialog for selecting a file or a remote server

So if they choose a file it defaults to local mode???
And if they choose a remote server (do you also ask them for a port) it
goes to network mode???

Are there more people that also submit command line args to the client appl? like optionally default RMI hostname and optionally default port?

Yes, BUT the argument is
to indicate what mode it runs in. It states:
Your programs must not require use of command line arguments other than the single mode flag, which must be supported. The mode flag must be either "server", indicating the server program must run, "alone", indicating standalone mode, or left out entirely, in which case the network client and gui must run.
I can safely say everyone I have spoken with has similar requirements and
are NOT given the flexibility to pass in such things as hostname,
database location,...etc. This has to come from your GUI via user input.
Pander Musubi
Greenhorn

Joined: May 15, 2003
Posts: 16
These requirements are not in my assignment, i think i have still an old assignment.
Anyways, trying to access anything on the disc after it fails to connect to rmi registry fails, even when I don't use a JFilCchooser and set the path hard in my code.
So my sollution is that this wierd behaviour of after "Connection refused to host" is to simply stop the program. Gonna document it and leave it at that. Think that is the most efficient sollution at this time.
Bill Robertson
Ranch Hand

Joined: Mar 21, 2003
Posts: 234
Sounds like a locking resources issue
Bharat Ruparel
Ranch Hand

Joined: Jul 30, 2003
Posts: 493
Hello Pander,
You should only be using the JFileChooser to locate the data file LOCALLY not REMOTELY! Therefore, by definition, no security issues should arise. This is not a Java bug, it definitely has to do with either your installation or your usage (by any chance, do you have any code in your JFileChooser event handlers refer to the RMI services?).
JFileChooser, in my opinion, is the way to go to locate the data file. Again, this is done on the server where the file is located so you shouldn't have any RMI related code in the event handlers for JFileChooser.
Hope this helps.
Regards.
Bharat


SCJP,SCJD,SCWCD,SCBCD,SCDJWS,SCEA
Bill Robertson
Ranch Hand

Joined: Mar 21, 2003
Posts: 234

You should only be using the JFileChooser to locate the data file LOCALLY not REMOTELY!

Did not even catch this one. This is absolutly true. How and why would you possibly display the underlying remote OS file system from another machine. And think about the process. When you start the server your sitting at the server machine so altough the server is the "remote" piece of your project its the local object at hand when you start the server. So your JFileChooser would reflect the local server's OS. Just as if your
running in local mode on your computer and you choose the database file
to run with in local mode.
Pander Musubi
Greenhorn

Joined: May 15, 2003
Posts: 16
Sorry to get you all confused.
I have a dialog which contains a JFileChooser AND some fields for selecting a remote server. So the user can choose what he or she wants. so the file choose is not used for selecting the remote server. Don't worry. Although when the remote server is not avaiable the whole thing crashes on the file chooser as described above.
Thanks,
P.
Bill Robertson
Ranch Hand

Joined: Mar 21, 2003
Posts: 234

Sorry to get you all confused.
I have a dialog which contains a JFileChooser AND some fields for selecting a remote server. So the user can choose what he or she wants. so the file choose is not used for selecting the remote server. Don't worry. Although when the remote server is not avaiable the whole thing crashes on the file chooser as described above.
Thanks,
P.

What do you mean when the remote server is not available. I am trying to
picture in my head your screen and the process flow your user goes through.
Lets say your user totally ignores the server fields and does not fill them
in, and instead just presses a button to kick off your file chooser, then
what happens? Is this where you get the error message? Are you sure your button to select the file chooser does NOTHING but select a file chooser.
Pander Musubi
Greenhorn

Joined: May 15, 2003
Posts: 16
No it is when a server name has been specified but actually no server is running. If you are really interested in this strage error I can send you my submission. Gonna submit it in a few days anyways and in my view it it finished. Can also send it or a part of it after the real submission when I have more time.
Bharat Ruparel
Ranch Hand

Joined: Jul 30, 2003
Posts: 493
Hello Pander,
Are you getting the same error using JFileChooser when you try to locate the data file in LOCAL mode? Realize that local mode should not involve any RMI or socket code.
If No RMI/Socket code is involved, please post code-snippets from your submission that deal with the JFileChooser dialog-box. It amounts to a few lines of code. Also, please provide the exact line in your code where you get the error.
Regards.
Bharat
Bill Robertson
Ranch Hand

Joined: Mar 21, 2003
Posts: 234
Gonna submit it in a few days anyways and in my view it it finished. Can also send it or a part of it after the real submission when I have more time.
Why send it when its not working? Send us over some of the code and
work it out. Your requirements would also help. As Bharat pointed out
there seems to be confusion in regards to what needs to happen in local
mode vs network mode. If this is the case there could be other important
fundamental problems within your code. I know it can get frustrating
but don't give up if you've come this far.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: bizar JFileChooser error after connection refused to localhost