This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes reading a .txt file from systemclassloader Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "reading a .txt file from systemclassloader" Watch "reading a .txt file from systemclassloader" New topic
Author

reading a .txt file from systemclassloader

Navin Keswani
Greenhorn

Joined: Jun 08, 2004
Posts: 17
Hi Guys,

I am somehow not able to read a .txt file from a SystemClassloader.

I think I am missing out on something but unable to findout.

I would really appreciate if someone could help me out as I have a deadline tday.

I have a file which is saved on my C:\Server\temp33 folder.

This path I have included in my System class path when I start my Weblogic server in its startweblogic.cmd file

here is the snippet:

CLASSPATH=%CLASSPATH%.;.\lib\weblogic_sp.jar;.\lib\weblogic.jar;%WL_HOME%\config\mydomain\applications\DefaultWebApp\WEB-INF\lib;%WL_HOME%\config\mydomain\applications\DefaultWebApp\WEB-INF\classes;%WL_HOME%\config\mydomain\applications\DefaultWebApp\WEB-INF\conf;C:\Server\temp33\;.;

Now I want to read a file which is stored in the temp33 folder in my applet which is a part of a WAR which is a part of an EAR.

Snippet of The Applet where I am trying to read the file:

datainputstream = new DataInputStream(ClassLoader.getSystemClassLoader().getResourceAsStream(filename));
System.out.println("GOT ^^^^^^^^^^^^^^^^^^^^^ ** ");
System.out.println("GOT INPUTSTREAM -**> "+ datainputstream.available());

But I am getting a null pointerexception at GOT INPUTSTREAM -**

The filename is a variable which I am passing to the applet through my JSP.

It could be anything like xyz.txt.

I think I am doing all the steps properly but may be I am missing out on something .

Regards,
Petr Blahos
Ranch Hand

Joined: Apr 28, 2004
Posts: 131
Well, I am not absolutely sure about it, but this might be the way:
You said that your war is in an ear. Try, if you can access a file in
your ear this way. If yes, getResource(" to your war") and work away on
the returned url.

I know that this is after your deadline, but just as a matter of
interest. Will you let us know if it worked?

Best regards,
Petr


Get a better web browser:<br /><a href="http://www.mozilla.org/products/firefox/switch.html" target="_blank" rel="nofollow">http://www.mozilla.org/products/firefox/switch.html</a>
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I'm not sure we're being given the whole picture.

My impression was that it was the Applet that was trying to load the txt file from the SystemClassLoader, and the applet security rules would certainly stop this from happening. I would have expected a SecurityException rather than a null return value though.

Dave.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: reading a .txt file from systemclassloader
 
Similar Threads
reading a .txt file from systemclassloader
WebLogic 6.0 -- The Hello World Example
ERROR 404 /HOW TO CONFIGURE WEBLOGIC
SystemClassLoader
Reading a .txt file from SystemClassloader