You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Jeroen Breedveld <je...@x-hive.com> on 2002/12/03 13:57:52 UTC

Custom anttask classloader problem

Hi all,

I created custom anttasks to perform common tasks on a database. The
database has a java interface but the kernel is written in C++ so JNI is
used to call functions in a windows DLL.

The problem I have is that when more than 1 of those custom anttasks are
used in 1 target I get the following error: 

  java.lang.UnsatisfiedLinkError: Native Library
C:\objy71\bin\oojava.dll already loaded in another classloader

This probably means that different classloaders are used for every
anttask. Is this true?
Is there a around this problem? Is there a way to use the same
classloader for every anttask?

The only solution I have come up with myself is putting every needed jar
in ANT_HOME/lib but this is not an elegant solution.

Here is a piece from my build file for clarity:

  <target name="load-taskdefs" depends="init">
    <taskdef name="createlibrary"
classname="com.xhive.anttasks.CreateLibrary"
classpathref="classpath"/>
    <taskdef name="parse"
classname="com.xhive.anttasks.Parse"
classpathref="classpath"/>
    <taskdef name="exportlibrary"
classname="com.xhive.anttasks.ExportLibrary"
classpathref="classpath"/>
    <taskdef name="elementindex"
classname="com.xhive.anttasks.indextasks.ElementIndex"
classpathref="classpath"/>
    <taskdef name="libraryIdIndex"
classname="com.xhive.anttasks.indextasks.LibraryIdIndex"
classpathref="classpath"/>
    <taskdef name="valueindex"
classname="com.xhive.anttasks.indextasks.ValueIndex"
classpathref="classpath"/>
    <taskdef name="deleteindex"
classname="com.xhive.anttasks.indextasks.DeleteIndex"
classpathref="classpath"/>
    <taskdef name="fulltextindex"
classname="com.xhive.anttasks.indextasks.FullTextIndex"
classpathref="classpath"/>
  </target>

  <target name="load-forms" depends="load-taskdefs">
    <createlibrary bootstrap="${bootstrap}"
                    database="${database}"
                        user="${user}"
                    password="${password}"
                        name="forms"
                      silent="true"/>
    <parse bootstrap="${bootstrap}"
            database="${database}"
                user="${user}"
            password="${password}"
              parent="/forms"
           namequery="namespace xhive = 'http://www.x-hive.com'
//xhive:id/@xhive:name"
               newer="true">
      <fileset dir="../data/forms">
        <include name="**/*"/>
      </fileset>
    </parse>
  </target>

thanks,

Jeroen Breedveld

--

X-Hive Corporation
e-mail: jeroenb@x-hive.com
phone: +31 10 7108622
http://www.x-hive.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>