• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

bizar JFileChooser error after connection refused to localhost

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like a locking resources issue
 
Ranch Hand
Posts: 493
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bill Robertson
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 493
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
The two armies met. But instead of battle, they decided to eat some pie and contemplate this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic