I would say that the JVM is searching for the file in its home directory.
I am not sure where that would be in JRun.
Here is a more reliable solution. Put the file in the JVMs classpath.
Then use the following code to retrieve and parse.
InputStream input = ClassLoader.getSystemResourceAsStream( "myxmlfile.xml"
);
parser.parse( new InputSource( input ) );
This should work. I have used it many times before.
Here is an example of how to set the classpath.
C:\junk\myxmlfile.xml
The classpath should include this directory:
C:\junk\
Once you have this all set up it will work.
There are many other solutions. You can use a web server to serve-up the
xml file that you desire, or specify the path directly in the parse method.
You will have to choose the one that best fits your situation.
Adam
Pascal
Troxler To: JRun-Talk
<[EMAIL PROTECTED]>
<admin@trosof cc:
t.ch> Subject: Re: file path
11/30/00
03:22 AM
Please
respond to
jrun-talk
>How are you accessing the XML file?
>Are you using ClassLoader.getResourceAsStream( "filename" )?
>Need some more information before I can give you a hand.
>Adam
The code is like this:
import org.xml.sax.*;
import org.w3c.dom.*;
import org.apache.xerces.parsers.DOMParser;
....
public void parse ( ) {
DOMParser parser = new DOMParser();
try {
parser.setFeature("
http://apache.org/xml/features/dom/defer-node-expansion",
false);
parser.setFeature("
http://apache.org/xml/features/continue-after-fatal-error",
true);
parser.setFeature("
http://apache.org/xml/features/allow-java-encodings",
true);
parser.parse ( "myxmlfile.xml" );
Document document = parser.getDocument();
NodeList list = document.getChildNodes();
.....
} catch (Exception e) {
....
}
*******
The Object "document" always gets NULL. So it seems he could not find the
file.
The Parser Object accepts a String or an InputSource Object as Parameter.
The InputSource constructor accepts a String or an InputStream.
Where is the jrun VM searching for the "myxmlfile.xml" ?
>Pascal Troxler
>University of Applied Sciences
>Biel, Switzerland
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Your ad could be here. Monies from ads go to support these lists and
provide more resources for the community.
http://www.fusionauthority.com/ads.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Your ad could be here. Monies from ads go to support these lists and provide more
resources for the community. http://www.fusionauthority.com/ads.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists