You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Rafael de F. Ferreira" <li...@rafaelferreira.net> on 2010/09/14 18:45:37 UTC

AntClassLoader and the system classloadr.

Hello.

I've run into an issue with ant's classloading strategy. When I try to
run a Java class with the <java> task, I get a ClassNotFoundException
for com.sun.xml.internal.ws.spi.ProviderImpl.

>From a cursory inspection of org.apache.tools.ant.AntClassLoader, it
seems Ant only delegates to the system  ClassLoader if the class being
loaded belongs to a fixed set of packages[1]. The problem occurs
because "com.sun.xml.internal" and it's sub-packages are not on this
set.

Is there any way to force ant to delegate class loading as specced?
Some other workaround would be fine as well (except fork='true').
Thanks.


[1] http://www.google.com/codesearch/p?hl=en#9iXYxNufh_Y/trunk/src/main/org/apache/tools/ant/util/JavaEnvUtils.java&l=324
--
Rafael de F. Ferreira.
http://www.rafaelferreira.net/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: AntClassLoader and the system classloadr.

Posted by Steve Loughran <st...@apache.org>.
On 15/09/10 05:27, Stefan Bodewig wrote:
> On 2010-09-14, Rafael de F. Ferreira wrote:
>
>>  From a cursory inspection of org.apache.tools.ant.AntClassLoader, it
>> seems Ant only delegates to the system ClassLoader if the class being
>> loaded belongs to a fixed set of packages[1].
>
> No, Ant almost always delegates to the system classloader first.
> AntClassLoader has a parentFirst option that can be used to make it look
> into its own classes before delegating when set to false (it is true by
> default).  The list of packages you've found are the packages that will
> always be loaded from the system classloader even if parentFirst is
> false.
>
>> I've run into an issue with ant's classloading strategy. When I try to
>> run a Java class with the<java>  task, I get a ClassNotFoundException
>> for com.sun.xml.internal.ws.spi.ProviderImpl.
>
> Are you sure the class is available from the system classloader?

It's in java 1.6.0_20,

package com.sun.xml.internal.ws.spi;

public static class ProviderImpl extends javax.xml.ws.spi.Provider { ... }

looks like part of JAX-WS

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: AntClassLoader and the system classloadr.

Posted by "Rafael de F. Ferreira" <li...@rafaelferreira.net>.
On Wed, Sep 15, 2010 at 1:27 AM, Stefan Bodewig <bo...@apache.org> wrote:
> On 2010-09-14, Rafael de F. Ferreira wrote:
>
>> From a cursory inspection of org.apache.tools.ant.AntClassLoader, it
>> seems Ant only delegates to the system ClassLoader if the class being
>> loaded belongs to a fixed set of packages[1].
>
> No, Ant almost always delegates to the system classloader first.
> AntClassLoader has a parentFirst option that can be used to make it look
> into its own classes before delegating when set to false (it is true by
> default).  The list of packages you've found are the packages that will
> always be loaded from the system classloader even if parentFirst is
> false.
>
>> I've run into an issue with ant's classloading strategy. When I try to
>> run a Java class with the <java> task, I get a ClassNotFoundException
>> for com.sun.xml.internal.ws.spi.ProviderImpl.
>
> Are you sure the class is available from the system classloader?

Yeah, you're right. The stack trace shows that AntClassLoader tries to
load with the parent classloader, catches CNFE and then tries to find
it by looking at the path components.

I'm actually using Ant's java task from Gradle and it's probably
messing up the parent classloader...

Thanks for the help.

>
> Stefan
>
>> [1] http://www.google.com/codesearch/p?hl=en#9iXYxNufh_Y/trunk/src/main/org/apache/tools/ant/util/JavaEnvUtils.java&l=324
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: AntClassLoader and the system classloadr.

Posted by Stefan Bodewig <bo...@apache.org>.
On 2010-09-14, Rafael de F. Ferreira wrote:

> From a cursory inspection of org.apache.tools.ant.AntClassLoader, it
> seems Ant only delegates to the system ClassLoader if the class being
> loaded belongs to a fixed set of packages[1].

No, Ant almost always delegates to the system classloader first.
AntClassLoader has a parentFirst option that can be used to make it look
into its own classes before delegating when set to false (it is true by
default).  The list of packages you've found are the packages that will
always be loaded from the system classloader even if parentFirst is
false.

> I've run into an issue with ant's classloading strategy. When I try to
> run a Java class with the <java> task, I get a ClassNotFoundException
> for com.sun.xml.internal.ws.spi.ProviderImpl.

Are you sure the class is available from the system classloader?

Stefan

> [1] http://www.google.com/codesearch/p?hl=en#9iXYxNufh_Y/trunk/src/main/org/apache/tools/ant/util/JavaEnvUtils.java&l=324

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


AW: AntClassLoader and the system classloadr.

Posted by Rainer Noack <ra...@noacks.net>.
Take a look at the <classloader> task from
http://enitsys.sourceforge.net/ant-classloadertask/

The easiest way might be, adding the classpath for your <java> task to the
project classloader.

BTW: <classloaderreport> fails for ant 1.8+
 
Regards

rainer

-----Ursprüngliche Nachricht-----
Von: rafaeldff@gmail.com [mailto:rafaeldff@gmail.com] Im Auftrag von Rafael
de F. Ferreira
Gesendet: Dienstag, 14. September 2010 18:46
An: user@ant.apache.org
Betreff: AntClassLoader and the system classloadr.

Hello.

I've run into an issue with ant's classloading strategy. When I try to run a
Java class with the <java> task, I get a ClassNotFoundException for
com.sun.xml.internal.ws.spi.ProviderImpl.

>From a cursory inspection of org.apache.tools.ant.AntClassLoader, it seems
Ant only delegates to the system  ClassLoader if the class being loaded
belongs to a fixed set of packages[1]. The problem occurs because
"com.sun.xml.internal" and it's sub-packages are not on this set.

Is there any way to force ant to delegate class loading as specced?
Some other workaround would be fine as well (except fork='true').
Thanks.


[1]
http://www.google.com/codesearch/p?hl=en#9iXYxNufh_Y/trunk/src/main/org/apac
he/tools/ant/util/JavaEnvUtils.java&l=324
--
Rafael de F. Ferreira.
http://www.rafaelferreira.net/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional
commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org