You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Rick Moynihan <ri...@calicojack.co.uk> on 2004/12/01 12:55:53 UTC
[digester] & resolving relative paths to canonical/absolute file
paths
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi all,
I'm using The Commons Digester to parse some XML and it all works fine.
~ I have some XML of the form:
<object>
~ <path>../relative/file/path</path>
</object>
Digester works perfectly and I can put the relative path (as specified
inside the <path> tags) into a java.io.File object.
However, when later on my program attempts to resovle this into either
an AbsoluteFilePath through java.io.File.getAbsoluteFile() or a
CanonicalFilePath file path through java.io.File.getCanonicalFile() I
get a null pointer exception similar to what is shown below:
Exception in thread "main" java.lang.NullPointerException
~ at java.io.UnixFileSystem.resolve(UnixFileSystem.java:92)
~ at java.io.UnixFileSystem.resolve(UnixFileSystem.java:118)
~ at java.io.File.getCanonicalPath(File.java:513)
~ at java.io.File.getCanonicalFile(File.java:534)
Some experimenting seems to have got me closer to the error, as I have
found that "pre digestion", i.e. prior to a call to
org.apache.commons.digester.Digester.parse(fileToParse)
System.getProperty("user.dir") returns a correct value (the path to the
directory where my JVM was instantiated).
However post digestion, and indeed during it,
System.getProperty("user.dir") ALWAYS returns null.
I was led to believe that this system property was read-only. I have
found this error occurs in both java v1.4.2-b28 and tiger (java v1.5).
It appears that digester or one of its dependencies is somehow reseting
the "user.dir" property. Is this a bug in Digester? Has anybody else
experienced anything like this.
Can anybody offer some help?
Rick.
p.s. I'd like to say: "Thanks to all the Apache developers, all the
projects I've run across have been excellent."
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFBrbFJi75r3xx6ZPYRAhnoAJ45pSPCUKO01Ac4trbZs601klOcsACdE7hJ
iEDS07sjDGp+HXZs7gNugdc=
=eTG7
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [digester] & resolving relative paths to canonical/absolute file
paths
Posted by Rick Moynihan <ri...@calicojack.co.uk>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
on 12/01/04 11:55 Rick Moynihan said the following:
|
| Hi all,
|
| I'm using The Commons Digester to parse some XML and it all works fine.
| ~ I have some XML of the form:
|
| <object>
| ~ <path>../relative/file/path</path>
| </object>
|
| Digester works perfectly and I can put the relative path (as specified
| inside the <path> tags) into a java.io.File object.
|
| However, when later on my program attempts to resovle this into either
| an AbsoluteFilePath through java.io.File.getAbsoluteFile() or a
| CanonicalFilePath file path through java.io.File.getCanonicalFile() I
| get a null pointer exception similar to what is shown below:
|
| Exception in thread "main" java.lang.NullPointerException
| ~ at java.io.UnixFileSystem.resolve(UnixFileSystem.java:92)
| ~ at java.io.UnixFileSystem.resolve(UnixFileSystem.java:118)
| ~ at java.io.File.getCanonicalPath(File.java:513)
| ~ at java.io.File.getCanonicalFile(File.java:534)
|
| Some experimenting seems to have got me closer to the error, as I have
| found that "pre digestion", i.e. prior to a call to
| org.apache.commons.digester.Digester.parse(fileToParse)
| System.getProperty("user.dir") returns a correct value (the path to the
| directory where my JVM was instantiated).
|
| However post digestion, and indeed during it,
| System.getProperty("user.dir") ALWAYS returns null.
|
| I was led to believe that this system property was read-only. I have
| found this error occurs in both java v1.4.2-b28 and tiger (java v1.5).
|
| It appears that digester or one of its dependencies is somehow reseting
| the "user.dir" property. Is this a bug in Digester? Has anybody else
| experienced anything like this.
|
| Can anybody offer some help?
|
|
| Rick.
|
| p.s. I'd like to say: "Thanks to all the Apache developers, all the
| projects I've run across have been excellent."
You should all disregard this... Some code of mine was reseting the
System properties rather than appending a set of new properties to it.
It's all thankfully resolved now...
Again thanks to the Apache teams for some excellent OSS work!
Cheers,
Rick.
- ---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFBrbkHi75r3xx6ZPYRArJ0AJ9NgEFkz7lnPWJj2CeASLcWbDY+BACfcTVF
JF44/V18wq5h4/wkOP8dRPU=
=xpbI
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org