You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Martin Monsorno <mo...@gmx.de> on 2002/06/19 16:53:22 UTC

sql-task uses system classloader

I do not know if this is a bug, but if not, there should be a BIG
warning in the documentation.

What happens is the following: if I have the CLASSPATH environment
variable set to the value "/path/to/version4/db2java.zip", and I run
ant with a build-script containing:
 
    <sql driver="COM.ibm.db2.jdbc.net.DB2Driver"
	 url="jdbc:db2://irgendwo:6790/mydb"
         ...>
      <classpath>
	<pathelement location="/path/to/version5/db2java.zip"
      </classpath>
    </sql>

then the JDBC-driver classes from the version4-db-driver, as defined
in the CLASSPATH env-var, are used.  As this is not the case for
e.g. java-tasks, this is _very_ uncomfortable.


-- 
Martin

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


Re: sql-task uses system classloader

Posted by Martin Monsorno <mo...@gmx.de>.
Stefan Bodewig <bo...@apache.org> writes:

> On Wed, 19 Jun 2002, Martin Monsorno <mo...@gmx.de> wrote:
>
>> I do not know if this is a bug, but if not, there should be a BIG
>> warning in the documentation.
>
> Well, it is yet another manifestation of
> <http://jakarta.apache.org/ant/faq.html#delegating-classloader>.
>
> A known problem with no real solution yet.

Two suggestions:

- a fork-attribute like with the java-task could make it possible to
  start a new JVM with different classpath setting

- it would be very handsome to make ant, if started with the -v
  option, not to print

      [sql] Loading COM.ibm.db2.jdbc.net.DB2Driver using
      AntClassLoader with classpath the.classpath.defined.in.sql.task 

  but instead:

      [sql] Loading COM.ibm.db2.jdbc.net.DB2Driver using system
      classloader with /CLASSPATH/ and
      AntClassLoader with classpath the.classpath.defined.in.sql.task 


And one more question:  Why does ant use the environment variable
CLASSPATH anyway?  It would be OK to restrict builds to define their
own classpath.  (or to make it configurable)


-- 
Martin

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


Re: sql-task uses system classloader

Posted by Stefan Bodewig <bo...@apache.org>.
On Wed, 19 Jun 2002, Martin Monsorno <mo...@gmx.de> wrote:

> I do not know if this is a bug, but if not, there should be a BIG
> warning in the documentation.

Well, it is yet another manifestation of
<http://jakarta.apache.org/ant/faq.html#delegating-classloader>.

A known problem with no real solution yet.

Stefan

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


Re: sql-task uses system classloader

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
----- Original Message -----
From: "Diane Holt" <ho...@yahoo.com>

> Of course, that's not always going to be practical. Some people actually
> run things on their computer that don't have anything to do with Ant (hard
> to believe, I know :)

Blasphemy!  :)

Ant makes a great launcher for Java programs, especially because of its
dealings with classpath internally for <java>.

    Erik



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


Re: sql-task uses system classloader

Posted by Diane Holt <ho...@yahoo.com>.
--- Erik Hatcher <ja...@ehatchersolutions.com> wrote:
> Well, its really a "best practice" if you run Ant without a system
> CLASSPATH set.

Of course, that's not always going to be practical. Some people actually
run things on their computer that don't have anything to do with Ant (hard
to believe, I know :)

Recommendation: Unset your CLASSPATH var in $HOME/.antrc (if you're
running on a Win*, dealing with the pre- and post- batch-file stuff is
left as an exercise for the reader :)

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

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


Re: sql-task uses system classloader

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
Well, its really a "best practice" if you run Ant without a system CLASSPATH
set.

Certainly the 1.x versions of Ant has its share of classpath/classloader
issues, as long as you play within Ant's constraints you should be fine, and
one of those is the preference to start with an empty CLASSPATH, put the
necessary dependencies in ANT_HOME/lib, and the others that can be referred
to dynamically using classapth constructs within the build file.

    Erik


----- Original Message -----
From: "Martin Monsorno" <mo...@gmx.de>
To: <an...@jakarta.apache.org>
Sent: Wednesday, June 19, 2002 10:53 AM
Subject: sql-task uses system classloader


> I do not know if this is a bug, but if not, there should be a BIG
> warning in the documentation.
>
> What happens is the following: if I have the CLASSPATH environment
> variable set to the value "/path/to/version4/db2java.zip", and I run
> ant with a build-script containing:
>
>     <sql driver="COM.ibm.db2.jdbc.net.DB2Driver"
> url="jdbc:db2://irgendwo:6790/mydb"
>          ...>
>       <classpath>
> <pathelement location="/path/to/version5/db2java.zip"
>       </classpath>
>     </sql>
>
> then the JDBC-driver classes from the version4-db-driver, as defined
> in the CLASSPATH env-var, are used.  As this is not the case for
> e.g. java-tasks, this is _very_ uncomfortable.
>
>
> --
> Martin
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


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