maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Frey" <qwer12...@gmx.ch>
Subject Maven classloader breaks URLs
Date Thu, 11 Nov 2004 23:22:57 GMT
Hello

I am using a method SharkUtils.class.getResource to load resources for my
project. The resource is lateron addressed as a file:

001  final String name = "sql/hsql/LoaderJob.olj";
002  final URL resource = SharkUtils.class.getResource(name);
003  final String external = resource.toExternalForm();
004  final URI uri = new URI(external);
005  final String string = uri.getRawPath();
006  final File file = new File(string);

Running such code in my IDE works great. The values of the variables (using
toString()) are:

001  sql/hsql/LoaderJob.olj
002
file:/E:/Daten/OrderManager/target/classes/ch/xmatrix/om/core/impl/shark/sql
/hsql/LoaderJob.olj
003
file:/E:/Daten/OrderManager/target/classes/ch/xmatrix/om/core/impl/shark/sql
/hsql/LoaderJob.olj
004
file:/E:/Daten/OrderManager/target/classes/ch/xmatrix/om/core/impl/shark/sql
/hsql/LoaderJob.olj
005
/E:/Daten/OrderManager/target/classes/ch/xmatrix/om/core/impl/shark/sql/hsql
/LoaderJob.olj
006
E:\Daten\OrderManager\target\classes\ch\xmatrix\om\core\impl\shark\sql\hsql\
LoaderJob.olj

However running it with maven (within a test case) failes. The values of the
variables are:

001  sql/hsql/LoaderJob.olj
002
file:E:/Daten/OrderManager/target/classes/ch/xmatrix/om/core/impl/shark/sql/
hsql/LoaderJob.olj
003
file:E:/Daten/OrderManager/target/classes/ch/xmatrix/om/core/impl/shark/sql/
hsql/LoaderJob.olj
004
file:E:/Daten/OrderManager/target/classes/ch/xmatrix/om/core/impl/shark/sql/
hsql/LoaderJob.olj
005  null
006  NPE

The difference is obvious. The URL is not translated to an absolute
reference, hence leading to a NPE. I do not know the internals of maven but:
If it uses an own class loader, this could explain the behaviour. Or do you
have another idea why the URL is not addressed absloutley? Any ideas to
resolve this issue?

Thanks
Daniel



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


Mime
View raw message