You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Detlef Brendle <de...@canoo.com> on 2001/07/19 12:29:13 UTC

classloader problems with dll

I compile a complete set of services ( one ant script calls several other
ant scripts)
If I run them separately it works allright -
However combined them together I get the following exception:
###################
libJNIExplorer.dll already loaded in another classloader
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1346)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1277)
        at java.lang.Runtime.load0(Runtime.java:698)
        at java.lang.System.load(System.java:797)
###################

I guess that two sub-ants try to load this dll file but the second process
cannot do so.
Can I split up the classloader and run the second ant-script who tries to
load this dll file in a complete different classloader?


detlef


Re: classloader problems with dll

Posted by Stefan Bodewig <bo...@apache.org>.
On Fri, 20 Jul 2001, Detlef Brendle <de...@canoo.com> wrote:

> I got the impression that it is not working very well. I still get
> the same message when running ant1.4alpha.

Could you please run it using the -debug switch?  You should (among a
whole lot of additional information) see lines like

>Implicitly adding /home/bodewig/junit/junit3.7/junit.jar to classpath
or
>Don't know how to handle resource URL systemresource:/ZIP2/+/junit/framework/TestCase.class
or
>Couldn't find /junit/framework/TestCase.class

once for junit.jar (/junit/framework/TestCase.class), ant.jar
(/org/apache/tools/ant/Task.class) and optional.jar
(/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.class).

In the case of "Don't know how to handle", I'd love to get hold of the
URL you see, so that I can fix the discovery algorithm, if possible.

Search somewhere at the top of the output, they are generated when the
task get's initialized (before any target is run).

Stefan

RE: classloader problems with dll

Posted by Detlef Brendle <de...@canoo.com>.

-----Original Message-----
From: ant-user-return-10457-detlef.brendle=canoo.com@jakarta.apache.org
[mailto:ant-user-return-10457-detlef.brendle=canoo.com@jakarta.apache.or
g]On Behalf Of Stefan Bodewig
Sent: Friday, July 20, 2001 3:12 PM
To: ant-user@jakarta.apache.org
Subject: Re: classloader problems with dll


On Fri, 20 Jul 2001, Detlef Brendle <de...@canoo.com> wrote:

> have u had success including the ant.jar, junit.jar and optional.jar

I think so, at least in my case it works if running a JDK > 1.1.
JDK 1.1 will not work, as the mechanism I use relies on the URL
Class.getResource() returns - and this one is unusable for archives in
JDK 1.1 (read, it doesn't contain the name of the archive).

Stefan

I got the impression that it is not working very well. I still get the same
message when running ant1.4alpha.
the error message is:

runTests:
    [junit] java.lang.NoClassDefFoundError:
org/apache/tools/ant/taskdefs/option
al/junit/JUnitTestRunner
    [junit] Exception in thread "main"

BUILD FAILED

I removed the pathelements from junit.jar,optional.jar, ant.jar.
the task looks like :

<target name="runTests">
  <junit printsummary="no" haltonfailure="yes" fork="yes">
    <classpath>
      <pathelement location="${build}"/>
	<!-- here was the path to the jar files. -->
      <pathelement location="${dist}/PerlTools.jar"/>
      <pathelement location="../../../lib/servlet.jar"/>
    </classpath>
    <formatter type="plain"/>
    <test name="${servicePackage}.AllTests"
outfile="TestResults-${serviceName}"/>
  </junit>
</target>


Re: classloader problems with dll

Posted by Stefan Bodewig <bo...@apache.org>.
On Fri, 20 Jul 2001, Detlef Brendle <de...@canoo.com> wrote:

> have u had success including the ant.jar, junit.jar and optional.jar

I think so, at least in my case it works if running a JDK > 1.1.  
JDK 1.1 will not work, as the mechanism I use relies on the URL
Class.getResource() returns - and this one is unusable for archives in
JDK 1.1 (read, it doesn't contain the name of the archive).

Stefan

RE: classloader problems with dll

Posted by Detlef Brendle <de...@canoo.com>.
have u had success including the ant.jar, junit.jar and optional.jar ???

it seems as if todays nightly build (20.07.)does not do this.

detlef

-----Original Message-----
From: ant-user-return-10420-detlef.brendle=canoo.com@jakarta.apache.org
[mailto:ant-user-return-10420-detlef.brendle=canoo.com@jakarta.apache.or
g]On Behalf Of Stefan Bodewig
Sent: Thursday, July 19, 2001 2:55 PM
To: ant-user@jakarta.apache.org
Subject: Re: classloader problems with dll


On Thu, 19 Jul 2001, Detlef Brendle <de...@canoo.com> wrote:

> <jvmarg line="-cp c:\jakarta\jakarta-ant-1.3-optional.jar"/>

instead of that, add 

<pathelement location="c:\jakarta\jakarta-ant-1.3-optional.jar"/>

to your <classpath>.

The current nightly build will try to include junit.jar, ant.jar and
optional.jar when you fork <junit>.

Stefan


Re: classloader problems with dll

Posted by Stefan Bodewig <bo...@apache.org>.
On Thu, 19 Jul 2001, Detlef Brendle <de...@canoo.com> wrote:

> <jvmarg line="-cp c:\jakarta\jakarta-ant-1.3-optional.jar"/>

instead of that, add 

<pathelement location="c:\jakarta\jakarta-ant-1.3-optional.jar"/>

to your <classpath>.

The current nightly build will try to include junit.jar, ant.jar and
optional.jar when you fork <junit>.

Stefan

RE: classloader problems with dll

Posted by Detlef Brendle <de...@canoo.com>.
hi Pete , thanks for your suggestion with fork.

for some reason I cant get it running.
my junit task looks like :

<target name="runTests">
  <junit printsummary="no" haltonfailure="yes" fork="yes">
    <classpath>
      <pathelement location="${build}"/>
      <pathelement location="${dist}/junit.jar"/>
      <pathelement location="${dist}/PerlTools.jar"/>
      <pathelement location="${dist}/Bag.jar"/>
      <pathelement location="${dist}/cutil.jar"/>
      <pathelement location="../../../lib/servlet.jar"/>
    </classpath>
    <formatter type="plain"/>
    <test name="${servicePackage}.AllTests"
outfile="TestResults-${serviceName}"/>
  </junit>
</target>


I looked into the <jvmarg> element. It says that I can add arguments the
same way than within <arg> itself.
But it cant find the JUnitTestRunner.class.
So I thought I add the following line to it:
<jvmarg line="-cp c:\jakarta\jakarta-ant-1.3-optional.jar"/>

it still cant find the JUnitTestRunner class.

what do I have todo here ?

can u help.


thanks,

detlef

-----Original Message-----
From: ant-user-return-10415-detlef.brendle=canoo.com@jakarta.apache.org
[mailto:ant-user-return-10415-detlef.brendle=canoo.com@jakarta.apache.or
g]On Behalf Of Peter Donald
Sent: Thursday, July 19, 2001 1:19 PM
To: ant-user@jakarta.apache.org
Subject: Re: classloader problems with dll


On Thu, 19 Jul 2001 20:29, Detlef Brendle wrote:
> I compile a complete set of services ( one ant script calls several other
> ant scripts)
> If I run them separately it works allright -
> However combined them together I get the following exception:
> ###################
> libJNIExplorer.dll already loaded in another classloader
>         at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1346)
>         at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1277)
>         at java.lang.Runtime.load0(Runtime.java:698)
>         at java.lang.System.load(System.java:797)
> ###################
>
> I guess that two sub-ants try to load this dll file but the second process
> cannot do so.
> Can I split up the classloader and run the second ant-script who tries to
> load this dll file in a complete different classloader?

It is not going to help unfortunatly. Most JVMs will only allow a native
library to be loaded once in the JVM. I would suggest that you use the java
task and set fork="true" when running the tool to make it work.

BTW you probably should not cross post multiple lists.

Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*


Re: classloader problems with dll

Posted by Peter Donald <do...@apache.org>.
On Thu, 19 Jul 2001 20:29, Detlef Brendle wrote:
> I compile a complete set of services ( one ant script calls several other
> ant scripts)
> If I run them separately it works allright -
> However combined them together I get the following exception:
> ###################
> libJNIExplorer.dll already loaded in another classloader
>         at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1346)
>         at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1277)
>         at java.lang.Runtime.load0(Runtime.java:698)
>         at java.lang.System.load(System.java:797)
> ###################
>
> I guess that two sub-ants try to load this dll file but the second process
> cannot do so.
> Can I split up the classloader and run the second ant-script who tries to
> load this dll file in a complete different classloader?

It is not going to help unfortunatly. Most JVMs will only allow a native 
library to be loaded once in the JVM. I would suggest that you use the java 
task and set fork="true" when running the tool to make it work. 

BTW you probably should not cross post multiple lists.

Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*