You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Stephen Duncan <st...@gmail.com> on 2006/05/03 00:32:39 UTC

JUnit Eclipse vs. Maven Question

I have a colleague with a problem running a JUnit test.  It works in
Eclipse, but not with Maven.

Basically, he uses a class that needs to load a native library.  The
location of a directory to look for this native .so object is
specified with java.library.path.

Initially, this value was not being set correctly because you must
specify it using <systemProperties>, not <argLine>.  We fixed that,
and now a debug output indicates that
System.getProperty("java.library.path") does return correctly. 
However, the error indicating that the native library could not be
found persists.  Any ideas on where else to look or tips on
troubleshooting?

--
Stephen Duncan Jr
www.stephenduncanjr.com

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


Re: JUnit Eclipse vs. Maven Question

Posted by Stephen Duncan <st...@gmail.com>.
It still doesn't work.  As I said before, setting it just in <argLine>
doesn't even result it in being set at all.  Any pointers on why that
might be?

-Stephen

On 5/3/06, Stephen Duncan <st...@gmail.com> wrote:
> I'll have him try it tomorrow.  However, we initially had it in the
> argLine, and it wasn't even setting the property at all (i.e.
> System.getProperty("java.library.path") returned the default value,
> not the value set in <argLine>).  I guess I can only try to do both &
> see what happens...
>
> -Stephen
>
> On 5/2/06, Kenney Westerhof <ke...@apache.org> wrote:
> > On Tue, 2 May 2006, Stephen Duncan wrote:
> >
> > > Sorry, forgot to mention that I tried with forkMode set to once & with
> > > it set to pertest.  Still didn't work.
> > >
> > > Could it be that <systemProperties> aren't passed to the JVM when it's
> > > forked?  They are only set afterwards?
> >
> > Took me some digging, but the system properties are loaded after the jvm
> > is started. The only way to define them in time is to define command line
> > arguments to the jvm: <argLine>-Djava.library.path=....</argLine> AND use
> > forkMode once or pertest.
> > You could also configure environment vars like LD_LIBRARY_PATH but that's
> > not really portable.
> >
> > Hope this helps,
> >
> > -- Kenney
> >
> > >
> > > -Stephen
> > >
> > > On 5/2/06, Kenney Westerhof <ke...@apache.org> wrote:
> > > > On Tue, 2 May 2006, Stephen Duncan wrote:
> > > >
> > > > Hi,
> > > >
> > > > The library path is only scanned on JVM startup; you can't modify it later
> > > > and expect the JRE to load any additional libraries.
> > > >
> > > > You'll have to use forked tests for that to work. Try configuring the
> > > > surefire plugin to have <forkMode>once</forkMode>, for instance.
> > > >
> > > > -- Kenney
> > > >
> > > >
> > > > > I have a colleague with a problem running a JUnit test.  It works in
> > > > > Eclipse, but not with Maven.
> > > > >
> > > > > Basically, he uses a class that needs to load a native library.  The
> > > > > location of a directory to look for this native .so object is
> > > > > specified with java.library.path.
> > > > >
> > > > > Initially, this value was not being set correctly because you must
> > > > > specify it using <systemProperties>, not <argLine>.  We fixed that,
> > > > > and now a debug output indicates that
> > > > > System.getProperty("java.library.path") does return correctly.
> > > > > However, the error indicating that the native library could not be
> > > > > found persists.  Any ideas on where else to look or tips on
> > > > > troubleshooting?
> > > > >
> > > > > --
> > > > > Stephen Duncan Jr
> > > > > www.stephenduncanjr.com
> > > > >
> > > > > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > > > For additional commands, e-mail: users-help@maven.apache.org
> > > > >
> > > > >
> > > >
> > > > --
> > > > Kenney Westerhof
> > > > http://www.neonics.com
> > > > GPG public key: http://www.gods.nl/~forge/kenneyw.key
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > > For additional commands, e-mail: users-help@maven.apache.org
> > > >
> > > >
> > >
> > >
> > > --
> > > Stephen Duncan Jr
> > > www.stephenduncanjr.com
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > For additional commands, e-mail: users-help@maven.apache.org
> > >
> > >
> >
> > --
> > Kenney Westerhof
> > http://www.neonics.com
> > GPG public key: http://www.gods.nl/~forge/kenneyw.key
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>
>
> --
> Stephen Duncan Jr
> www.stephenduncanjr.com
>


--
Stephen Duncan Jr
www.stephenduncanjr.com

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


Re: JUnit Eclipse vs. Maven Question

Posted by Stephen Duncan <st...@gmail.com>.
I'll have him try it tomorrow.  However, we initially had it in the
argLine, and it wasn't even setting the property at all (i.e.
System.getProperty("java.library.path") returned the default value,
not the value set in <argLine>).  I guess I can only try to do both &
see what happens...

-Stephen

On 5/2/06, Kenney Westerhof <ke...@apache.org> wrote:
> On Tue, 2 May 2006, Stephen Duncan wrote:
>
> > Sorry, forgot to mention that I tried with forkMode set to once & with
> > it set to pertest.  Still didn't work.
> >
> > Could it be that <systemProperties> aren't passed to the JVM when it's
> > forked?  They are only set afterwards?
>
> Took me some digging, but the system properties are loaded after the jvm
> is started. The only way to define them in time is to define command line
> arguments to the jvm: <argLine>-Djava.library.path=....</argLine> AND use
> forkMode once or pertest.
> You could also configure environment vars like LD_LIBRARY_PATH but that's
> not really portable.
>
> Hope this helps,
>
> -- Kenney
>
> >
> > -Stephen
> >
> > On 5/2/06, Kenney Westerhof <ke...@apache.org> wrote:
> > > On Tue, 2 May 2006, Stephen Duncan wrote:
> > >
> > > Hi,
> > >
> > > The library path is only scanned on JVM startup; you can't modify it later
> > > and expect the JRE to load any additional libraries.
> > >
> > > You'll have to use forked tests for that to work. Try configuring the
> > > surefire plugin to have <forkMode>once</forkMode>, for instance.
> > >
> > > -- Kenney
> > >
> > >
> > > > I have a colleague with a problem running a JUnit test.  It works in
> > > > Eclipse, but not with Maven.
> > > >
> > > > Basically, he uses a class that needs to load a native library.  The
> > > > location of a directory to look for this native .so object is
> > > > specified with java.library.path.
> > > >
> > > > Initially, this value was not being set correctly because you must
> > > > specify it using <systemProperties>, not <argLine>.  We fixed that,
> > > > and now a debug output indicates that
> > > > System.getProperty("java.library.path") does return correctly.
> > > > However, the error indicating that the native library could not be
> > > > found persists.  Any ideas on where else to look or tips on
> > > > troubleshooting?
> > > >
> > > > --
> > > > Stephen Duncan Jr
> > > > www.stephenduncanjr.com
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > > For additional commands, e-mail: users-help@maven.apache.org
> > > >
> > > >
> > >
> > > --
> > > Kenney Westerhof
> > > http://www.neonics.com
> > > GPG public key: http://www.gods.nl/~forge/kenneyw.key
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > For additional commands, e-mail: users-help@maven.apache.org
> > >
> > >
> >
> >
> > --
> > Stephen Duncan Jr
> > www.stephenduncanjr.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>
> --
> Kenney Westerhof
> http://www.neonics.com
> GPG public key: http://www.gods.nl/~forge/kenneyw.key
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


--
Stephen Duncan Jr
www.stephenduncanjr.com

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


Re: JUnit Eclipse vs. Maven Question

Posted by Kenney Westerhof <ke...@apache.org>.
On Tue, 2 May 2006, Stephen Duncan wrote:

> Sorry, forgot to mention that I tried with forkMode set to once & with
> it set to pertest.  Still didn't work.
>
> Could it be that <systemProperties> aren't passed to the JVM when it's
> forked?  They are only set afterwards?

Took me some digging, but the system properties are loaded after the jvm
is started. The only way to define them in time is to define command line
arguments to the jvm: <argLine>-Djava.library.path=....</argLine> AND use
forkMode once or pertest.
You could also configure environment vars like LD_LIBRARY_PATH but that's
not really portable.

Hope this helps,

-- Kenney

>
> -Stephen
>
> On 5/2/06, Kenney Westerhof <ke...@apache.org> wrote:
> > On Tue, 2 May 2006, Stephen Duncan wrote:
> >
> > Hi,
> >
> > The library path is only scanned on JVM startup; you can't modify it later
> > and expect the JRE to load any additional libraries.
> >
> > You'll have to use forked tests for that to work. Try configuring the
> > surefire plugin to have <forkMode>once</forkMode>, for instance.
> >
> > -- Kenney
> >
> >
> > > I have a colleague with a problem running a JUnit test.  It works in
> > > Eclipse, but not with Maven.
> > >
> > > Basically, he uses a class that needs to load a native library.  The
> > > location of a directory to look for this native .so object is
> > > specified with java.library.path.
> > >
> > > Initially, this value was not being set correctly because you must
> > > specify it using <systemProperties>, not <argLine>.  We fixed that,
> > > and now a debug output indicates that
> > > System.getProperty("java.library.path") does return correctly.
> > > However, the error indicating that the native library could not be
> > > found persists.  Any ideas on where else to look or tips on
> > > troubleshooting?
> > >
> > > --
> > > Stephen Duncan Jr
> > > www.stephenduncanjr.com
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > For additional commands, e-mail: users-help@maven.apache.org
> > >
> > >
> >
> > --
> > Kenney Westerhof
> > http://www.neonics.com
> > GPG public key: http://www.gods.nl/~forge/kenneyw.key
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>
>
> --
> Stephen Duncan Jr
> www.stephenduncanjr.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

--
Kenney Westerhof
http://www.neonics.com
GPG public key: http://www.gods.nl/~forge/kenneyw.key

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


Re: JUnit Eclipse vs. Maven Question

Posted by Stephen Duncan <st...@gmail.com>.
Sorry, forgot to mention that I tried with forkMode set to once & with
it set to pertest.  Still didn't work.

Could it be that <systemProperties> aren't passed to the JVM when it's
forked?  They are only set afterwards?

-Stephen

On 5/2/06, Kenney Westerhof <ke...@apache.org> wrote:
> On Tue, 2 May 2006, Stephen Duncan wrote:
>
> Hi,
>
> The library path is only scanned on JVM startup; you can't modify it later
> and expect the JRE to load any additional libraries.
>
> You'll have to use forked tests for that to work. Try configuring the
> surefire plugin to have <forkMode>once</forkMode>, for instance.
>
> -- Kenney
>
>
> > I have a colleague with a problem running a JUnit test.  It works in
> > Eclipse, but not with Maven.
> >
> > Basically, he uses a class that needs to load a native library.  The
> > location of a directory to look for this native .so object is
> > specified with java.library.path.
> >
> > Initially, this value was not being set correctly because you must
> > specify it using <systemProperties>, not <argLine>.  We fixed that,
> > and now a debug output indicates that
> > System.getProperty("java.library.path") does return correctly.
> > However, the error indicating that the native library could not be
> > found persists.  Any ideas on where else to look or tips on
> > troubleshooting?
> >
> > --
> > Stephen Duncan Jr
> > www.stephenduncanjr.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>
> --
> Kenney Westerhof
> http://www.neonics.com
> GPG public key: http://www.gods.nl/~forge/kenneyw.key
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


--
Stephen Duncan Jr
www.stephenduncanjr.com

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


Re: JUnit Eclipse vs. Maven Question

Posted by Kenney Westerhof <ke...@apache.org>.
On Tue, 2 May 2006, Stephen Duncan wrote:

Hi,

The library path is only scanned on JVM startup; you can't modify it later
and expect the JRE to load any additional libraries.

You'll have to use forked tests for that to work. Try configuring the
surefire plugin to have <forkMode>once</forkMode>, for instance.

-- Kenney


> I have a colleague with a problem running a JUnit test.  It works in
> Eclipse, but not with Maven.
>
> Basically, he uses a class that needs to load a native library.  The
> location of a directory to look for this native .so object is
> specified with java.library.path.
>
> Initially, this value was not being set correctly because you must
> specify it using <systemProperties>, not <argLine>.  We fixed that,
> and now a debug output indicates that
> System.getProperty("java.library.path") does return correctly.
> However, the error indicating that the native library could not be
> found persists.  Any ideas on where else to look or tips on
> troubleshooting?
>
> --
> Stephen Duncan Jr
> www.stephenduncanjr.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

--
Kenney Westerhof
http://www.neonics.com
GPG public key: http://www.gods.nl/~forge/kenneyw.key

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