Results 1 to 12 of 12
Thread: [SOLVED] Server file loading
- 04-17-2009, 06:34 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 8
- Rep Power
- 0
[SOLVED] Server file loading
I have developed a java applet which loads a file from its own directory. This works brilliantly when ran from eclipse.
I have moved the applet to my server along with the files and i keep getting:
I have read the information about permissions here duckware.com/applets/reference.html#securitymodelJava Code:java.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read) 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.checkPropertyAccess(Unknown Source) at java.lang.System.getProperty(Unknown Source) at weka.core.converters.AbstractFileLoader.<init>(AbstractFileLoader.java:46) at weka.core.converters.ArffLoader.<init>(ArffLoader.java:56) at weka.core.converters.ConverterUtils$DataSource.<init>(ConverterUtils.java:127) at Data.dataset.loadfile(dataset.java:120)
I have 4 folders containing class files on my server siu05dr.webs.sse.reading.ac.uk
The applet is within one of these folders (main). I have moved the files (cpu.arff, iris.arff etc.) i would like opening to this same folder on the server and am accessing using this command:
It is then opened and parsed using the WEKA libraries ARFF parsers.Java Code:new URL(cpu.arff)
I have also tried
but still get security issues.Java Code:new URL(./cpu.arff)
What am i doing wrong? am i correct in thinking that you can load files from where the applet is located?
Any help would be really great
SIAS
- 04-17-2009, 06:46 PM #2
Member
- Join Date
- Mar 2009
- Posts
- 8
- Rep Power
- 0
- 04-17-2009, 07:00 PM #3
If you try to use file operations in an applet it will try to access files on the client machine - which is not allowed.
To access files from the server, either put them in the jar and use getResourceAsStream() or write a server you connect to with some kind of socket.Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
- 04-18-2009, 12:06 AM #4
Member
- Join Date
- Mar 2009
- Posts
- 8
- Rep Power
- 0
Thanks for the reply, that explains alot.
The weka library i am using only supports reading files or URLs. Is there any other way of getting around this?
If I used getResourceAsStream() would it be treated as a File or another data object?
If i digitally signed my applet would the method i am currently using work?
Thanks for your help so far
Dan
- 04-18-2009, 12:33 AM #5
The method returns an InputStream. These abstract away whether the source is a File, Socket or whatever. There's a similar method getResource() that returns a URL object.
Alternatively use URLs that point to your server. That means using full paths like http://www.example.org/files/cpu.arff
Using the File API will work only if the files you want to access are already on the client computer.Last edited by OrangeDog; 04-18-2009 at 12:36 AM.
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
- 04-18-2009, 01:26 AM #6
Member
- Join Date
- Mar 2009
- Posts
- 8
- Rep Power
- 0
I have tried loading an URL using the full path but received the same security error.
I will try the resource method.
Thank you
- 04-18-2009, 01:59 AM #7
If it's another error thrown by weka.core.converters.AbstractFileLoader.<init> then it may be the case that the library isn't ever going to work in an applet. Look for a method that takes some kind of stream to load data from, or complain to the developers to put one in (or become a developer and put it in yourself).
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
- 04-18-2009, 09:38 PM #8
Member
- Join Date
- Mar 2009
- Posts
- 8
- Rep Power
- 0
Ok, i have found another project using weka to open ARFF files from a URL. (hakank.org/weka simple weka program 1)
I looked at his code and have replicated what he did. This is the solution he is using:
I am now getting this error when run:Java Code:BufferedReader reader = null; URL url = new URL(filename); reader = new BufferedReader (new InputStreamReader( (InputStream) url.getContent() ));
Any ideas?Java Code:java.security.AccessControlException: access denied (java.net.SocketPermission siu05dr.webs.sse.reading.ac.uk:80 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 sun.plugin2.applet.Applet2SecurityManager.checkConnect(Unknown Source) at sun.net.ww.http.HttpClient.openServer(Unknown Source) at sun.net.ww.http.HttpClient.<init>(Unknown Source) at sun.net.ww.http.HttpClient.New(Unknown Source) at sun.net.ww.http.HttpClient.New(Unknown Source) at sun.net.ww.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source) at sun.net.ww.protocol.http.HttpURLConnection.plainConnect(Unknown Source) at sun.net.ww.protocol.http.HttpURLConnection.connect(Unknown Source) at sun.net.ww.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at java.net.URLConnection.getContent(Unknown Source) at java.net.URL.getContent(Unknown Source) at Data.dataset.loadfile(dataset.java:126) at Main.applet$10.mouseClicked(applet.java:401) at java.awt.AWTEventMulticaster.mouseClicked(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)
Thanks so much for your help so far
p.s. had to change www -> ww due to the forum restrictions on posting links
Dan
- 04-18-2009, 10:18 PM #9
Yes, an untrusted applet can only open connections to the server from which it was downloaded.
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
- 04-19-2009, 12:54 AM #10
Member
- Join Date
- Mar 2009
- Posts
- 8
- Rep Power
- 0
I uploaded the applet to the server containing the files.
I now get this error:
Thanks for all your helpJava Code:java.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read) 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.checkPropertyAccess(Unknown Source) at java.lang.System.getProperty(Unknown Source) at weka.core.converters.AbstractFileLoader.<init>(AbstractFileLoader.java:46) at weka.core.converters.ArffLoader.<init>(ArffLoader.java:56) at weka.core.converters.ConverterUtils$DataSource.<init>(ConverterUtils.java:127) at Data.dataset.loadfile(dataset.java:120) at Main.applet$10.mouseClicked(applet.java:402) at java.awt.AWTEventMulticaster.mouseClicked(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)
- 04-19-2009, 01:06 AM #11
Now your applet is trying to read the users' home directory. Either you got your paths wrong or that library really wasn't designed to be used in an applet, the naughty thing.
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
- 04-22-2009, 11:23 PM #12
Member
- Join Date
- Mar 2009
- Posts
- 8
- Rep Power
- 0
Similar Threads
-
loading .properties file dynamically
By nanaji in forum Advanced JavaReplies: 3Last Post: 03-17-2009, 03:40 AM -
loading a text file
By nick2price in forum New To JavaReplies: 2Last Post: 12-24-2008, 12:46 AM -
error while loading the image from the server
By testtest in forum CLDC and MIDPReplies: 1Last Post: 09-23-2008, 05:16 AM -
Loading of JSP file failed
By Heather in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 08-06-2007, 01:15 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks