You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Adam Perry-Pelletier <ad...@moesol.com> on 2005/07/14 19:52:17 UTC

JNI dll gets loaded multiple times during JUnit tests

I'm converting an opensource project to use maven.  The is a java COM
wrapper.  Accordingly, it relies on underlying JNI and dlls for the native
support.  When running its JUnit tests, I get the following error.

 

Testcase:
testEnv(com.moesol.bindings.platform_sdk.base_services.ProcessTest):Ca

used an ERROR

Native Library C:\Program Files\USMC\CJB\com_moesol_bindings.dll already
loaded

in another classloader

java.lang.UnsatisfiedLinkError: Native Library C:\Program Files\CJB\com_moe

sol_bindings.dll already loaded in another classloader

        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1551)

        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1482)

        at java.lang.Runtime.load0(Runtime.java:737)

        at java.lang.System.load(System.java:811)

        at
com.moesol.bindings.NativeLibraryLoader.load(NativeLibraryLoader.java

 

The native library is getting loaded multiple times by the class loader.  We
have static blocks that load the libraries for every test.  This does work
under ant, presumably because ant fully unloads each test case after it is
tested, thus the dlls aren't loaded more than once.

 

Can anyone provide guidance on how to work around this.

 

Thanks,

Adam


Re: JNI dll gets loaded multiple times during JUnit tests

Posted by Doug Douglass <dd...@denverdata.com>.
Just a suggestion, try adding:

maven.junit.fork=true

to your project.properties.

Doug

Adam Perry-Pelletier wrote:

>I'm converting an opensource project to use maven.  The is a java COM
>wrapper.  Accordingly, it relies on underlying JNI and dlls for the native
>support.  When running its JUnit tests, I get the following error.
>
> 
>
>Testcase:
>testEnv(com.moesol.bindings.platform_sdk.base_services.ProcessTest):Ca
>
>used an ERROR
>
>Native Library C:\Program Files\USMC\CJB\com_moesol_bindings.dll already
>loaded
>
>in another classloader
>
>java.lang.UnsatisfiedLinkError: Native Library C:\Program Files\CJB\com_moe
>
>sol_bindings.dll already loaded in another classloader
>
>        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1551)
>
>        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1482)
>
>        at java.lang.Runtime.load0(Runtime.java:737)
>
>        at java.lang.System.load(System.java:811)
>
>        at
>com.moesol.bindings.NativeLibraryLoader.load(NativeLibraryLoader.java
>
> 
>
>The native library is getting loaded multiple times by the class loader.  We
>have static blocks that load the libraries for every test.  This does work
>under ant, presumably because ant fully unloads each test case after it is
>tested, thus the dlls aren't loaded more than once.
>
> 
>
>Can anyone provide guidance on how to work around this.
>
> 
>
>Thanks,
>
>Adam
>
>
>  
>

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


Re: JNI dll gets loaded multiple times during JUnit tests

Posted by Kenney Westerhof <fo...@neonics.com>.
On Thu, 14 Jul 2005, Adam Perry-Pelletier wrote:

You could use a TestSuite that does the dll initialization and contains
(references to) all the TestCases, which of course no longer load the
dll.

I'm not entirely sure about the details, but I bet the JUnit documentation
can be helpful there.

-- Kenney

> I'm converting an opensource project to use maven.  The is a java COM
> wrapper.  Accordingly, it relies on underlying JNI and dlls for the native
> support.  When running its JUnit tests, I get the following error.
>
>
>
> Testcase:
> testEnv(com.moesol.bindings.platform_sdk.base_services.ProcessTest):Ca
>
> used an ERROR
>
> Native Library C:\Program Files\USMC\CJB\com_moesol_bindings.dll already
> loaded
>
> in another classloader
>
> java.lang.UnsatisfiedLinkError: Native Library C:\Program Files\CJB\com_moe
>
> sol_bindings.dll already loaded in another classloader
>
>         at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1551)
>
>         at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1482)
>
>         at java.lang.Runtime.load0(Runtime.java:737)
>
>         at java.lang.System.load(System.java:811)
>
>         at
> com.moesol.bindings.NativeLibraryLoader.load(NativeLibraryLoader.java
>
>
>
> The native library is getting loaded multiple times by the class loader.  We
> have static blocks that load the libraries for every test.  This does work
> under ant, presumably because ant fully unloads each test case after it is
> tested, thus the dlls aren't loaded more than once.
>
>
>
> Can anyone provide guidance on how to work around this.
>
>
>
> Thanks,
>
> Adam
>
>

--
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