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 <qw...@gmx.ch> on 2004/11/11 12:51:13 UTC
Maven classloader breaks URLs
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
Re: AW: Maven classloader breaks URLs
Posted by Milos Kleint <Mi...@Sun.COM>.
if you install mevenide for netbeans, it should be able to do it for
you. (http://mevenide.codehaus.org/download.html)
You just open the project from the IDE, set the breakpoint in the test
and find the debug test action in main menu.
It's using a mevenide in-house maven plugin that does exactly that,
allowing you to run the test with debug args and connects the IDE's
debugger to it.. The connection part is a bit shaky, but generally works.
You can actuallyuse the maven-plugin itself separately on the command
line as well, see
http://mevenide.codehaus.org/maven-mevenide-plugin/index.html for details.
Regards
Milos Kleint
Brett Porter wrote:
>I thnik it is maven.junit.jvmargs (check the test plugin doco), where
>you can specify -Xdebug etc then connect using your IDE using a remote
>debugger (JPDA).
>
>Cheers,
>Brett
>
>
>On Fri, 12 Nov 2004 11:02:17 +0100, Daniel Frey <da...@xmatrix.ch> wrote:
>
>
>>Thanks for the hint. It solves the problem partly. But I get wired
>>behaviour, directories are not created aso. Is there a way to debug the
>>projects source code line by line within my IDE when the tests are run with
>>maven?
>>
>>-----Ursprüngliche Nachricht-----
>>Von: Brett Porter [mailto:brett.porter@gmail.com]
>>Gesendet: Donnerstag, 11. November 2004 23:33
>>An: Maven Users List
>>Betreff: Re: Maven classloader breaks URLs
>>
>>I'd have to look closer to understand this and see whether it is a real
>>problem or not, but a possible workaround is to have your tests in a forked
>>JVM?
>>
>>maven.junit.fork=true
>>
>>- Brett
>>
>>On Thu, 11 Nov 2004 12:51:13 +0100, Daniel Frey <qw...@gmx.ch> wrote:
>>
>>
>>>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/sha
>>>rk/sql
>>>/hsql/LoaderJob.olj
>>>003
>>>file:/E:/Daten/OrderManager/target/classes/ch/xmatrix/om/core/impl/sha
>>>rk/sql
>>>/hsql/LoaderJob.olj
>>>004
>>>file:/E:/Daten/OrderManager/target/classes/ch/xmatrix/om/core/impl/sha
>>>rk/sql
>>>/hsql/LoaderJob.olj
>>>005
>>>/E:/Daten/OrderManager/target/classes/ch/xmatrix/om/core/impl/shark/sq
>>>l/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/shar
>>>k/sql/
>>>hsql/LoaderJob.olj
>>>003
>>>file:E:/Daten/OrderManager/target/classes/ch/xmatrix/om/core/impl/shar
>>>k/sql/
>>>hsql/LoaderJob.olj
>>>004
>>>file:E:/Daten/OrderManager/target/classes/ch/xmatrix/om/core/impl/shar
>>>k/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
>>>
>>>
>>>
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>>
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>For additional commands, e-mail: users-help@maven.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: AW: Maven classloader breaks URLs
Posted by Brett Porter <br...@gmail.com>.
I thnik it is maven.junit.jvmargs (check the test plugin doco), where
you can specify -Xdebug etc then connect using your IDE using a remote
debugger (JPDA).
Cheers,
Brett
On Fri, 12 Nov 2004 11:02:17 +0100, Daniel Frey <da...@xmatrix.ch> wrote:
> Thanks for the hint. It solves the problem partly. But I get wired
> behaviour, directories are not created aso. Is there a way to debug the
> projects source code line by line within my IDE when the tests are run with
> maven?
>
> -----Ursprüngliche Nachricht-----
> Von: Brett Porter [mailto:brett.porter@gmail.com]
> Gesendet: Donnerstag, 11. November 2004 23:33
> An: Maven Users List
> Betreff: Re: Maven classloader breaks URLs
>
> I'd have to look closer to understand this and see whether it is a real
> problem or not, but a possible workaround is to have your tests in a forked
> JVM?
>
> maven.junit.fork=true
>
> - Brett
>
> On Thu, 11 Nov 2004 12:51:13 +0100, Daniel Frey <qw...@gmx.ch> wrote:
> > 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/sha
> > rk/sql
> > /hsql/LoaderJob.olj
> > 003
> > file:/E:/Daten/OrderManager/target/classes/ch/xmatrix/om/core/impl/sha
> > rk/sql
> > /hsql/LoaderJob.olj
> > 004
> > file:/E:/Daten/OrderManager/target/classes/ch/xmatrix/om/core/impl/sha
> > rk/sql
> > /hsql/LoaderJob.olj
> > 005
> > /E:/Daten/OrderManager/target/classes/ch/xmatrix/om/core/impl/shark/sq
> > l/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/shar
> > k/sql/
> > hsql/LoaderJob.olj
> > 003
> > file:E:/Daten/OrderManager/target/classes/ch/xmatrix/om/core/impl/shar
> > k/sql/
> > hsql/LoaderJob.olj
> > 004
> > file:E:/Daten/OrderManager/target/classes/ch/xmatrix/om/core/impl/shar
> > k/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
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
AW: Maven classloader breaks URLs
Posted by Daniel Frey <da...@xmatrix.ch>.
Thanks for the hint. It solves the problem partly. But I get wired
behaviour, directories are not created aso. Is there a way to debug the
projects source code line by line within my IDE when the tests are run with
maven?
-----Ursprüngliche Nachricht-----
Von: Brett Porter [mailto:brett.porter@gmail.com]
Gesendet: Donnerstag, 11. November 2004 23:33
An: Maven Users List
Betreff: Re: Maven classloader breaks URLs
I'd have to look closer to understand this and see whether it is a real
problem or not, but a possible workaround is to have your tests in a forked
JVM?
maven.junit.fork=true
- Brett
On Thu, 11 Nov 2004 12:51:13 +0100, Daniel Frey <qw...@gmx.ch> wrote:
> 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/sha
> rk/sql
> /hsql/LoaderJob.olj
> 003
> file:/E:/Daten/OrderManager/target/classes/ch/xmatrix/om/core/impl/sha
> rk/sql
> /hsql/LoaderJob.olj
> 004
> file:/E:/Daten/OrderManager/target/classes/ch/xmatrix/om/core/impl/sha
> rk/sql
> /hsql/LoaderJob.olj
> 005
> /E:/Daten/OrderManager/target/classes/ch/xmatrix/om/core/impl/shark/sq
> l/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/shar
> k/sql/
> hsql/LoaderJob.olj
> 003
> file:E:/Daten/OrderManager/target/classes/ch/xmatrix/om/core/impl/shar
> k/sql/
> hsql/LoaderJob.olj
> 004
> file:E:/Daten/OrderManager/target/classes/ch/xmatrix/om/core/impl/shar
> k/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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Maven classloader breaks URLs
Posted by Brett Porter <br...@gmail.com>.
I'd have to look closer to understand this and see whether it is a
real problem or not, but a possible workaround is to have your tests
in a forked JVM?
maven.junit.fork=true
- Brett
On Thu, 11 Nov 2004 12:51:13 +0100, Daniel Frey <qw...@gmx.ch> wrote:
> 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org