You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Daniel Frey <da...@xmatrix.ch> on 2004/03/22 09:26:13 UTC

getResource returning relative path

Hi there,

When I use maven to run a test, which includes loading a resource with
MyTest.class.getResource("fileName"), the method returns a relativ path.

file:E:/Daten/UPS/ch.xmatrix.gui.splash-impl/target/test-classes/afterClick.
png

There the leading slash is missing. Consequently, an exception is then
thrown.

URI is not hierarchical
java.lang.IllegalArgumentException: URI is not hierarchical
        at java.io.File.<init>(File.java:321)
        ...

When I run it from my IDE, then the correct path is returned with the
exactly same code:

file:/E:/Daten/UPS/ch.xmatrix.gui.splash-impl/target/test-classes/afterClick
.png

I suppose there is a classloader problem. Could it have to do with maven?

Daniel Frey


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org