Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > web start, security element, resource loading problem

Reply
Thread Tools

web start, security element, resource loading problem

 
 
Honglin Ye
Guest
Posts: n/a
 
      08-19-2003

Hi,
I need to feed a data file to a dataset in a web start application. The program runs fine on local.

In the jnlp,
(1) if set security element to j2ee-application-client-permissions,
I got "ava.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)"
(2) if set security element to all-permissions
I got "java.io.FileNotFoundException: C:\Documents and Settings\hye\Desktop\file:\C:\Program Files\Java Web
Start\.javaws\cache\http\Dbernoulli.aoc.nrao.edu\P 80\DMe2e\DMcalib3\RMCalib3.jar!\calib3\src_parm_po s_datafile.txt (The filename, directory name, or volume label syntax is
incorrect)
It seems the class loader picked up an extra prefix "C:\Documents and Settings\hye\Desktop" for the file.

Any one know why? Thanks

Honglin Ye



-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      08-19-2003
On Tue, 19 Aug 2003 16:44:49 -0600, Honglin Ye <(E-Mail Removed)>
wrote or quoted :

>Any one know why? Thanks

Try running Wassup to look at the system properties. That may give you
a clue.

See http://mindprod.com/jgloss/wassup.html

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
 
 
 
Honglin Ye
Guest
Posts: n/a
 
      08-20-2003
Roedy Green wrote:
> On Tue, 19 Aug 2003 16:44:49 -0600, Honglin Ye <(E-Mail Removed)>
> wrote or quoted :
>
>
>>Any one know why? Thanks

>
> Try running Wassup to look at the system properties. That may give you
> a clue.
>
> See http://mindprod.com/jgloss/wassup.html
>
> --
> Canadian Mind Products, Roedy Green.
> Coaching, problem solving, economical contract programming.
> See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.

------------------------------------------------------------------------------------------

Thanks, Roedy, Here is the report from from wassup. I could not find theproblem there.
Also, the jar file is downloaded, but it did not add to the app manager, why?

Thanks again.
Honglin Ye


awt.toolkit = sun.awt.windows.WToolkit

file.encoding = Cp1252

file.encoding.pkg = sun.io

file.separator = \

java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment

java.awt.printerjob = sun.awt.windows.WPrinterJob

java.class.path = D:\PROGRA~1\Java\J2RE14~1.1\classes

java.class.version = 48.0

java.ext.dirs = D:\PROGRA~1\Java\J2RE14~1.1\lib\ext

java.home = D:\PROGRA~1\Java\J2RE14~1.1

java.io.tmpdir = C:\DOCUME~1\hye\LOCALS~1\Temp\

java.library.path = D:\Program Files\Netscape\Netscape;.;C:\WINNT\System32;C:\WIN NT;d:\Program Files\Netscape\Netscape\;D:\oracle\ora81\bin;C:\Pr ogram
Files\Oracle\jre\1.1.7\bin;C:\WINNT\system32;C:\WI NNT;C:\WINNT\System32\Wbem;C:\Program Files\Common Files\Adaptec Shared\System;"D:\Program
Files\Hummingbird\Connectivity\7.00\Accessories\"; D:\Program Files\Rational\common;D:\BorlandEnterpriseServer\b in;D:\oracle\ora81\bin;C:\Program
Files\Oracle\jre\1.1.7\bin;C:\WINNT\system32;C:\WI NNT;C:\WINNT\System32\Wbem;C:\Program Files\Common Files\Adaptec Shared\System;"D:\Program
Files\Hummingbird\Connectivity\7.00\Accessories\"; D:\Program
Files\Rational\common;D:\BorlandEnterpriseServer\b in;d:\j2ee\bin;d:\j2sdk1.4.0\bin;D:\j2ee\jakarta-ant-1.3\bin;D:\BorlandEnterpriseServer\bin

java.specification.name = Java Platform API Specification

java.specification.vendor = Sun Microsystems Inc.

java.specification.version = 1.4

java.vendor = Sun Microsystems Inc.

java.vendor.url = http://java.sun.com/

java.vendor.url.bug = http://java.sun.com/cgi-bin/bugreport.cgi

java.version = 1.4.1

java.vm.info = mixed mode

java.vm.name = Java HotSpot(TM) Client VM

java.vm.specification.name = Java Virtual Machine Specification

java.vm.specification.vendor = Sun Microsystems Inc.

java.vm.specification.version = 1.0

java.vm.vendor = Sun Microsystems Inc.

java.vm.version = 1.4.1-b21

line.separator = [binary chars: 0x0d 0x0a i.e. CrLf, \r\n]

os.arch = x86

os.name = Windows 2000

os.version = 5.0

path.separator = ;

sun.boot.class.path =
D:\PROGRA~1\Java\J2RE14~1.1\lib\rt.jar;D:\PROGRA~1 \Java\J2RE14~1.1\lib\i18n.jar;D:\PROGRA~1\Java\J2R E14~1.1\lib\sunrsasign.jar;D:\PROGRA~1\Java\J2RE14 ~1.1\lib\jsse.jar;D:\PROGRA~1\Java\J2RE14~1.1\lib\ jce.jar;D:\PROGRA~1\Java\J2RE14~1.1\lib\charsets.j ar;D:\PROGRA~1\Java\J2RE14~1.1\classes;D:\PROGRA~1 \Java\J2RE14~1.1\lib\jaws.jar

sun.boot.library.path = D:\PROGRA~1\Java\J2RE14~1.1\bin

sun.io.unicode.encoding = UnicodeLittle

user.dir = d:\Program Files\Netscape\Netscape

user.home = C:\Documents and Settings\hye

user.language = en

user.name = hye

user.timezone = America/Denver




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      08-20-2003
On Tue, 19 Aug 2003 16:44:49 -0600, Honglin Ye <(E-Mail Removed)>
wrote or quoted :

> It seems the class loader picked up an extra prefix "C:\Documents and Settings\hye\Desktop" for the file.

So it is looking in user.home.
user.home = C:\Documents and Settings\hye

I think the key may be dumping out
new File(".").getCanonicalPath().

To find out what the current directory is under various circumstances.

Just WHAT is it looking in that directory for?

My guess is some sort of properties file.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      08-20-2003
On Wed, 20 Aug 2003 13:52:18 -0600, Honglin Ye <(E-Mail Removed)>
wrote or quoted :

>java.io.FileNotFoundException: file:\C:\Program Files\Java Web Start\.javaws\cache\http\Dbernoulli.aoc.nrao.edu\P 80\DMe2e\DMcalib3\RMCalib3.jar!\calib3\alias_dataf ile.txt


It is hard debugging without seeing the source code. I have to make a
lot of guesses. That is not a valid FILE name. That is an URL of a
member of a jar. I think you were trying to use file methods to read
a jar member. Zips are something like subdirectories, but are not
treated that way by Java. You need totally different methods to read
them.


See http://mindprod.com/fileio.html for how to read given an URL.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      08-21-2003
On Thu, 21 Aug 2003 12:09:06 -0600, Honglin Ye <(E-Mail Removed)>
wrote or quoted :

> private void readFromFile(URL aliasFileName) {
> FileReader fileReader;
> char data[] = new char[1024];


Please reread my earlier post. You cannot use FileReader to look
inside a Jar.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
Honglin Ye
Guest
Posts: n/a
 
      08-21-2003
Roedy Green wrote:
> On Thu, 21 Aug 2003 12:09:06 -0600, Honglin Ye <(E-Mail Removed)>
> wrote or quoted :
>
>
>> private void readFromFile(URL aliasFileName) {
>> FileReader fileReader;
>> char data[] = new char[1024];

>
>
> Please reread my earlier post. You cannot use FileReader to look
> inside a Jar.
>
> --
> Canadian Mind Products, Roedy Green.
> Coaching, problem solving, economical contract programming.
> See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.


Did read it. Read from FileReader is to verify the point - it does
not work for the file that is in a jar file.

Again, the objective is to use borland TableDataSet classs. The
construct of that class takes a file name as argument. The question
is - what if that file is in a jar file? It seems that it behaves
just like the case of using FileReader.



-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      08-21-2003
On Thu, 21 Aug 2003 15:00:59 -0600, Honglin Ye <(E-Mail Removed)>
wrote or quoted :

>
>Did read it. Read from FileReader is to verify the point - it does
>not work for the file that is in a jar file.


If you want to read an URL you have to do something like this.
Are you telling me this does NOT work on file:! Jar-type URLs?
If not, then you are going to have to use the ZIP classes.

// Read Locale-encoded chars ( usually 8 bit ) from a buffered URL.
// WARNING! unsigned Applets may only read from the server they were
loaded from.
// Sockets are a low level tool. For HTTP you will see all the headers
and length bytes.
// For HTTP normally you want the HttpURLConnection rather than
Socket.
// To copy/download files see
http://mindprod.com/products.html#FILETRANSFER.

// import java.io.*;
// import java.net.*;

// O P E N
// Generate an HTTP GET Command
URL url = new URL( "http://www.billabong.com:80/songs/lyrics.txt" );
URLConnection urlc = url.openConnection();
urlc.setAllowUserInteraction( false );
urlc.setDoInput( true );
urlc.setDoOutput( false );
urlc.setUseCaches( false );
urlc.connect();
long length = urlc.getContentLength(); // -1 if not available
// if you want to analyse the URL
String protocol = url.getProtocol(); // http
String host = url.getHost(); // www.billabong.com
String file = url.getFile(); // lyrics.txt
int port = url.getPort();// 80
InputStream is = urlc.getInputStream();
InputStreamReader eisr = new InputStreamReader( is,"Cp437" );
// Cp437 is IBM OEM.
// See "encoding" in the Java glossary for alternatives
// such as UnicodeBig for 16-bit, big-endian Unicode characters.
BufferedReader br = new BufferedReader( eisr, 4096 /* buffsize */ );

// R E A D
char[] ca = new char[1024];
int charsRead = br.read( ca );
String line;
// File being read had better have a terminal \n!
line = br.readLine();
// line == null means EOF
int aChar;
aChar = br.read();
// aChar == -1 means EOF

// C L O S E
br.close();
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
Honglin Ye
Guest
Posts: n/a
 
      08-22-2003
Roedy Green wrote:
> On Thu, 21 Aug 2003 15:00:59 -0600, Honglin Ye <(E-Mail Removed)>
> wrote or quoted :
>
>
>>Did read it. Read from FileReader is to verify the point - it does
>>not work for the file that is in a jar file.

>
>
> If you want to read an URL you have to do something like this.
> Are you telling me this does NOT work on file:! Jar-type URLs?
> If not, then you are going to have to use the ZIP classes.
>
> // Read Locale-encoded chars ( usually 8 bit ) from a buffered URL.
> // WARNING! unsigned Applets may only read from the server they were
> loaded from.
> // Sockets are a low level tool. For HTTP you will see all the headers
> and length bytes.
> // For HTTP normally you want the HttpURLConnection rather than
> Socket.
> // To copy/download files see
> http://mindprod.com/products.html#FILETRANSFER.
>
> // import java.io.*;
> // import java.net.*;
>
> // O P E N
> // Generate an HTTP GET Command
> URL url = new URL( "http://www.billabong.com:80/songs/lyrics.txt" );
> URLConnection urlc = url.openConnection();
> urlc.setAllowUserInteraction( false );
> urlc.setDoInput( true );
> urlc.setDoOutput( false );
> urlc.setUseCaches( false );
> urlc.connect();
> long length = urlc.getContentLength(); // -1 if not available
> // if you want to analyse the URL
> String protocol = url.getProtocol(); // http
> String host = url.getHost(); // www.billabong.com
> String file = url.getFile(); // lyrics.txt
> int port = url.getPort();// 80
> InputStream is = urlc.getInputStream();
> InputStreamReader eisr = new InputStreamReader( is,"Cp437" );
> // Cp437 is IBM OEM.
> // See "encoding" in the Java glossary for alternatives
> // such as UnicodeBig for 16-bit, big-endian Unicode characters.
> BufferedReader br = new BufferedReader( eisr, 4096 /* buffsize */ );
>
> // R E A D
> char[] ca = new char[1024];
> int charsRead = br.read( ca );
> String line;
> // File being read had better have a terminal \n!
> line = br.readLine();
> // line == null means EOF
> int aChar;
> aChar = br.read();
> // aChar == -1 means EOF
>
> // C L O S E
> br.close();
> --
> Canadian Mind Products, Roedy Green.
> Coaching, problem solving, economical contract programming.
> See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.


I have no problem read from stream which connected in a file in a jar.
You can look at my code I posted on 8/21, 12:09pm. I have a method there
called readFromStream. That method works even it is not the same as you
posted here. Infact, we do not necessarily need URLConnnection, the
following line is sufficient to get the stream. It works.
-----------
InputStream is = this.getClass().getClassLoader().getResourceAsStre am("calib3/alias_datafile.txt");
-----------

The situation is this:
TableDataSet takes file, but not file in a jar.
read from filereader does not work for file in a jar.
read from stream works well for file in a jar.
TableDataSet does not take stream directly.
How to make TableDataSet to work if the file is in a jar?



-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
 
Reply With Quote
 
Honglin Ye
Guest
Posts: n/a
 
      08-22-2003

>
> The situation is this:
> TableDataSet takes file, but not file in a jar.
> read from filereader does not work for file in a jar.
> read from stream works well for file in a jar.
> TableDataSet does not take stream directly.
> How to make TableDataSet to work if the file is in a jar?
>
>


It turns out extremly easy. Just 3 lines of code!

private TextDataFile aliasDataFile = new TextDataFile();
public TableDataSet aliasTableDataSet = new TableDataSet();

InputStream dataStream = this.getClass().getClassLoader().getResourceAsStre am("calib3/alias_datafile.txt");
aliasDataFile.load(aliasTableDataSet, dataStream, null);

Thanks.

Honglin Ye






-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Resource expression to access resource located in library Heinrich Moser ASP .Net 1 03-27-2008 04:25 PM
Very annoying error: Access to the path is denied. ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity Jay ASP .Net 2 08-20-2007 07:38 PM
Resource manager problem: naming for embedded resource. Dirc Khan-Evans ASP .Net 1 10-17-2005 12:52 PM
The system cannot locate the resource specified. Error processing resource avishosh XML 2 08-08-2004 06:28 AM
Strange simple resource loading problem Daniel Java 9 02-24-2004 03:14 AM



Advertisments