You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Nicolas Lalevée <ni...@hibnet.org> on 2014/05/11 23:41:23 UTC
Classloading issue
Hi,
I need some help to understand a bug around classloading (nothing that particular to Ivy).
I was looking into IVY-1471 [1] and I don't understand why it is failing that way. In the classpath there are both Ivy and Jsch, but not the optional jar related to managing the ssh agent via jsch. And it is failing because a class in that optional jar is not found. But I don't understand why the classloader is looking for it in the first place.
The error is raised is AbstractSshBasedRepository, on the call of SshCache.getInstance() [2]. But as far as I can tell, nothing in the loading of the SshCache [3] class requires AgentProxyException. The class is only needed by the function SshCache#attemptAgentUse() [4], which will be called at runtime, if the end user actually want ssh agent support, in which case it would naturally fail. But here it fails very earlier.
I have made a test case you can test with its build.xml, no IvyDE required there [5].
Am I missing something ? Is there a special treatment for the loading of Exception classes ?
Nicolas
[1] https://issues.apache.org/jira/browse/IVY-1471
[2] https://fisheye6.atlassian.com/browse/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/AbstractSshBasedRepository.java?hb=true#to108
[3] https://fisheye6.atlassian.com/browse/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshCache.java?hb=true
[4] https://fisheye6.atlassian.com/browse/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshCache.java?hb=true#to300
[5] http://svn.apache.org/repos/asf/ant/ivy/ivyde/trunk/test/ssh-resolver/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: Classloading issue
Posted by Charles Duffy <ch...@dyfis.net>.
I was thinking of doing a runtime type check on the exception returned
(grabbing an instance of the class via introspection, to avoid a
classload-time dependency) and reraising anything unexpected wrapped in a
RuntimeException; otherwise, that's pretty much exactly the way I would
have fixed the issue.
On Tue, May 13, 2014 at 11:55 AM, Nicolas Lalevée <
nicolas.lalevee@hibnet.org> wrote:
> r1594279 seems to fix the issue, but I still don't understand why.
> Any suggestion of a better fix is welcomed.
>
> Nicolas
>
> Le 11 mai 2014 à 23:41, Nicolas Lalevée <ni...@hibnet.org> a
> écrit :
>
> > Hi,
> >
> > I need some help to understand a bug around classloading (nothing that
> particular to Ivy).
> >
> > I was looking into IVY-1471 [1] and I don't understand why it is failing
> that way. In the classpath there are both Ivy and Jsch, but not the
> optional jar related to managing the ssh agent via jsch. And it is failing
> because a class in that optional jar is not found. But I don't understand
> why the classloader is looking for it in the first place.
> >
> > The error is raised is AbstractSshBasedRepository, on the call of
> SshCache.getInstance() [2]. But as far as I can tell, nothing in the
> loading of the SshCache [3] class requires AgentProxyException. The class
> is only needed by the function SshCache#attemptAgentUse() [4], which will
> be called at runtime, if the end user actually want ssh agent support, in
> which case it would naturally fail. But here it fails very earlier.
> >
> > I have made a test case you can test with its build.xml, no IvyDE
> required there [5].
> >
> > Am I missing something ? Is there a special treatment for the loading of
> Exception classes ?
> >
> > Nicolas
> >
> > [1] https://issues.apache.org/jira/browse/IVY-1471
> > [2]
> https://fisheye6.atlassian.com/browse/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/AbstractSshBasedRepository.java?hb=true#to108
> > [3]
> https://fisheye6.atlassian.com/browse/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshCache.java?hb=true
> > [4]
> https://fisheye6.atlassian.com/browse/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshCache.java?hb=true#to300
> > [5]
> http://svn.apache.org/repos/asf/ant/ivy/ivyde/trunk/test/ssh-resolver/
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> > For additional commands, e-mail: dev-help@ant.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
>
Re: Classloading issue
Posted by Nicolas Lalevée <ni...@hibnet.org>.
r1594279 seems to fix the issue, but I still don't understand why.
Any suggestion of a better fix is welcomed.
Nicolas
Le 11 mai 2014 à 23:41, Nicolas Lalevée <ni...@hibnet.org> a écrit :
> Hi,
>
> I need some help to understand a bug around classloading (nothing that particular to Ivy).
>
> I was looking into IVY-1471 [1] and I don't understand why it is failing that way. In the classpath there are both Ivy and Jsch, but not the optional jar related to managing the ssh agent via jsch. And it is failing because a class in that optional jar is not found. But I don't understand why the classloader is looking for it in the first place.
>
> The error is raised is AbstractSshBasedRepository, on the call of SshCache.getInstance() [2]. But as far as I can tell, nothing in the loading of the SshCache [3] class requires AgentProxyException. The class is only needed by the function SshCache#attemptAgentUse() [4], which will be called at runtime, if the end user actually want ssh agent support, in which case it would naturally fail. But here it fails very earlier.
>
> I have made a test case you can test with its build.xml, no IvyDE required there [5].
>
> Am I missing something ? Is there a special treatment for the loading of Exception classes ?
>
> Nicolas
>
> [1] https://issues.apache.org/jira/browse/IVY-1471
> [2] https://fisheye6.atlassian.com/browse/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/AbstractSshBasedRepository.java?hb=true#to108
> [3] https://fisheye6.atlassian.com/browse/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshCache.java?hb=true
> [4] https://fisheye6.atlassian.com/browse/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshCache.java?hb=true#to300
> [5] http://svn.apache.org/repos/asf/ant/ivy/ivyde/trunk/test/ssh-resolver/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: Classloading issue
Posted by Nicolas Lalevée <ni...@hibnet.org>.
Le 12 mai 2014 à 02:51, Martin Gainty <mg...@hotmail.com> a écrit :
>> Subject: Re: Classloading issue
>> From: nicolas.lalevee@hibnet.org
>> Date: Mon, 12 May 2014 01:51:12 +0200
>> To: dev@ant.apache.org
>>
>>
>> Le 12 mai 2014 à 01:34, Antoine Levy Lambert <an...@gmx.de> a écrit :
>>
>>> Hello Nicolas,
>>>
>>> I have tried your test case and it is failing as you except :
>>>
>>> BUILD FAILED
>>> /Users/antoine/dev/asf/ivyde-trunk/test/ssh-resolver/build.xml:27: java.lang.NoClassDefFoundError: com/jcraft/jsch/agentproxy/AgentProxyException
>
> MG>Hi Nicholas
> MG>local classloader cannot resolve jdsch-agentproxy.core-0.0.7.jar?
> MG>what happens when you place
> MG>http://www.grepcode.com/snapshot/repo1.maven.org/maven2/com.jcraft/jsch.agentproxy.core/0.0.7/jsch.agentproxy.core-0.0.7.jar
> MG>on SYSTEM classpath?
jsch-agentproxy isn't on the classpath on purpose. If we don't need the ssh agent feature, we shouldn't need this jar.
Nicolas
>
>>> at org.apache.ivy.plugins.repository.ssh.AbstractSshBasedRepository.getSession(AbstractSshBasedRepository.java:108)
>>> at org.apache.ivy.plugins.repository.ssh.SshRepository.resolveResource(SshRepository.java:82)
>>> at org.apache.ivy.plugins.repository.ssh.SshResource.resolve(SshResource.java:101)
>>>
>>> The line 108 in AbstractSsshBasedRepository contains this :
>>>
>>> return SshCache.getInstance().getSession(host, port, user, userPassword, getKeyFile(),
>>> getKeyFilePassword(), getPassFile(), isAllowedAgentUse());
>>>
>>> getSession is a method which calls attemptAgentUse.
>>
>> It is only called is attemptAgentUse is true. In our case it is false.
>>
>>> Does this explain why an attempt to load AgentProxyException happens at that time ?
>>
>> I have plugged a debugger, and the class loading exception is raised on the call of SshCache.getInstance(). As far as I can tell, it is the class SshCache which fails to load, but I don't understand why.
>>
>> Nicolas
>>
>>>
>>> Regards,
>>>
>>> Antoine
>>>
>>> On May 11, 2014, at 5:41 PM, Nicolas Lalevée <ni...@hibnet.org> wrote:
>>>
>>>> Hi,
>>>>
>>>> I need some help to understand a bug around classloading (nothing that particular to Ivy).
>>>>
>>>> I was looking into IVY-1471 [1] and I don't understand why it is failing that way. In the classpath there are both Ivy and Jsch, but not the optional jar related to managing the ssh agent via jsch. And it is failing because a class in that optional jar is not found. But I don't understand why the classloader is looking for it in the first place.
>>>>
>>>> The error is raised is AbstractSshBasedRepository, on the call of SshCache.getInstance() [2]. But as far as I can tell, nothing in the loading of the SshCache [3] class requires AgentProxyException. The class is only needed by the function SshCache#attemptAgentUse() [4], which will be called at runtime, if the end user actually want ssh agent support, in which case it would naturally fail. But here it fails very earlier.
>>>>
>>>> I have made a test case you can test with its build.xml, no IvyDE required there [5].
>>>>
>>>> Am I missing something ? Is there a special treatment for the loading of Exception classes ?
>>>>
>>>> Nicolas
>>>>
>>>> [1] https://issues.apache.org/jira/browse/IVY-1471
>>>> [2] https://fisheye6.atlassian.com/browse/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/AbstractSshBasedRepository.java?hb=true#to108
>>>> [3] https://fisheye6.atlassian.com/browse/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshCache.java?hb=true
>>>> [4] https://fisheye6.atlassian.com/browse/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshCache.java?hb=true#to300
>>>> [5] http://svn.apache.org/repos/asf/ant/ivy/ivyde/trunk/test/ssh-resolver/
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>>>> For additional commands, e-mail: dev-help@ant.apache.org
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>>> For additional commands, e-mail: dev-help@ant.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>> For additional commands, e-mail: dev-help@ant.apache.org
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
RE: Classloading issue
Posted by Martin Gainty <mg...@hotmail.com>.
> Subject: Re: Classloading issue
> From: nicolas.lalevee@hibnet.org
> Date: Mon, 12 May 2014 01:51:12 +0200
> To: dev@ant.apache.org
>
>
> Le 12 mai 2014 à 01:34, Antoine Levy Lambert <an...@gmx.de> a écrit :
>
> > Hello Nicolas,
> >
> > I have tried your test case and it is failing as you except :
> >
> > BUILD FAILED
> > /Users/antoine/dev/asf/ivyde-trunk/test/ssh-resolver/build.xml:27: java.lang.NoClassDefFoundError: com/jcraft/jsch/agentproxy/AgentProxyException
MG>Hi Nicholas
MG>local classloader cannot resolve jdsch-agentproxy.core-0.0.7.jar?
MG>what happens when you place
MG>http://www.grepcode.com/snapshot/repo1.maven.org/maven2/com.jcraft/jsch.agentproxy.core/0.0.7/jsch.agentproxy.core-0.0.7.jar
MG>on SYSTEM classpath?
> > at org.apache.ivy.plugins.repository.ssh.AbstractSshBasedRepository.getSession(AbstractSshBasedRepository.java:108)
> > at org.apache.ivy.plugins.repository.ssh.SshRepository.resolveResource(SshRepository.java:82)
> > at org.apache.ivy.plugins.repository.ssh.SshResource.resolve(SshResource.java:101)
> >
> > The line 108 in AbstractSsshBasedRepository contains this :
> >
> > return SshCache.getInstance().getSession(host, port, user, userPassword, getKeyFile(),
> > getKeyFilePassword(), getPassFile(), isAllowedAgentUse());
> >
> > getSession is a method which calls attemptAgentUse.
>
> It is only called is attemptAgentUse is true. In our case it is false.
>
> > Does this explain why an attempt to load AgentProxyException happens at that time ?
>
> I have plugged a debugger, and the class loading exception is raised on the call of SshCache.getInstance(). As far as I can tell, it is the class SshCache which fails to load, but I don't understand why.
>
> Nicolas
>
> >
> > Regards,
> >
> > Antoine
> >
> > On May 11, 2014, at 5:41 PM, Nicolas Lalevée <ni...@hibnet.org> wrote:
> >
> >> Hi,
> >>
> >> I need some help to understand a bug around classloading (nothing that particular to Ivy).
> >>
> >> I was looking into IVY-1471 [1] and I don't understand why it is failing that way. In the classpath there are both Ivy and Jsch, but not the optional jar related to managing the ssh agent via jsch. And it is failing because a class in that optional jar is not found. But I don't understand why the classloader is looking for it in the first place.
> >>
> >> The error is raised is AbstractSshBasedRepository, on the call of SshCache.getInstance() [2]. But as far as I can tell, nothing in the loading of the SshCache [3] class requires AgentProxyException. The class is only needed by the function SshCache#attemptAgentUse() [4], which will be called at runtime, if the end user actually want ssh agent support, in which case it would naturally fail. But here it fails very earlier.
> >>
> >> I have made a test case you can test with its build.xml, no IvyDE required there [5].
> >>
> >> Am I missing something ? Is there a special treatment for the loading of Exception classes ?
> >>
> >> Nicolas
> >>
> >> [1] https://issues.apache.org/jira/browse/IVY-1471
> >> [2] https://fisheye6.atlassian.com/browse/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/AbstractSshBasedRepository.java?hb=true#to108
> >> [3] https://fisheye6.atlassian.com/browse/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshCache.java?hb=true
> >> [4] https://fisheye6.atlassian.com/browse/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshCache.java?hb=true#to300
> >> [5] http://svn.apache.org/repos/asf/ant/ivy/ivyde/trunk/test/ssh-resolver/
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> >> For additional commands, e-mail: dev-help@ant.apache.org
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> > For additional commands, e-mail: dev-help@ant.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
Re: Classloading issue
Posted by Nicolas Lalevée <ni...@hibnet.org>.
Le 12 mai 2014 à 01:34, Antoine Levy Lambert <an...@gmx.de> a écrit :
> Hello Nicolas,
>
> I have tried your test case and it is failing as you except :
>
> BUILD FAILED
> /Users/antoine/dev/asf/ivyde-trunk/test/ssh-resolver/build.xml:27: java.lang.NoClassDefFoundError: com/jcraft/jsch/agentproxy/AgentProxyException
> at org.apache.ivy.plugins.repository.ssh.AbstractSshBasedRepository.getSession(AbstractSshBasedRepository.java:108)
> at org.apache.ivy.plugins.repository.ssh.SshRepository.resolveResource(SshRepository.java:82)
> at org.apache.ivy.plugins.repository.ssh.SshResource.resolve(SshResource.java:101)
>
> The line 108 in AbstractSsshBasedRepository contains this :
>
> return SshCache.getInstance().getSession(host, port, user, userPassword, getKeyFile(),
> getKeyFilePassword(), getPassFile(), isAllowedAgentUse());
>
> getSession is a method which calls attemptAgentUse.
It is only called is attemptAgentUse is true. In our case it is false.
> Does this explain why an attempt to load AgentProxyException happens at that time ?
I have plugged a debugger, and the class loading exception is raised on the call of SshCache.getInstance(). As far as I can tell, it is the class SshCache which fails to load, but I don't understand why.
Nicolas
>
> Regards,
>
> Antoine
>
> On May 11, 2014, at 5:41 PM, Nicolas Lalevée <ni...@hibnet.org> wrote:
>
>> Hi,
>>
>> I need some help to understand a bug around classloading (nothing that particular to Ivy).
>>
>> I was looking into IVY-1471 [1] and I don't understand why it is failing that way. In the classpath there are both Ivy and Jsch, but not the optional jar related to managing the ssh agent via jsch. And it is failing because a class in that optional jar is not found. But I don't understand why the classloader is looking for it in the first place.
>>
>> The error is raised is AbstractSshBasedRepository, on the call of SshCache.getInstance() [2]. But as far as I can tell, nothing in the loading of the SshCache [3] class requires AgentProxyException. The class is only needed by the function SshCache#attemptAgentUse() [4], which will be called at runtime, if the end user actually want ssh agent support, in which case it would naturally fail. But here it fails very earlier.
>>
>> I have made a test case you can test with its build.xml, no IvyDE required there [5].
>>
>> Am I missing something ? Is there a special treatment for the loading of Exception classes ?
>>
>> Nicolas
>>
>> [1] https://issues.apache.org/jira/browse/IVY-1471
>> [2] https://fisheye6.atlassian.com/browse/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/AbstractSshBasedRepository.java?hb=true#to108
>> [3] https://fisheye6.atlassian.com/browse/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshCache.java?hb=true
>> [4] https://fisheye6.atlassian.com/browse/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshCache.java?hb=true#to300
>> [5] http://svn.apache.org/repos/asf/ant/ivy/ivyde/trunk/test/ssh-resolver/
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>> For additional commands, e-mail: dev-help@ant.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: Classloading issue
Posted by Antoine Levy Lambert <an...@gmx.de>.
Hello Nicolas,
I have tried your test case and it is failing as you except :
BUILD FAILED
/Users/antoine/dev/asf/ivyde-trunk/test/ssh-resolver/build.xml:27: java.lang.NoClassDefFoundError: com/jcraft/jsch/agentproxy/AgentProxyException
at org.apache.ivy.plugins.repository.ssh.AbstractSshBasedRepository.getSession(AbstractSshBasedRepository.java:108)
at org.apache.ivy.plugins.repository.ssh.SshRepository.resolveResource(SshRepository.java:82)
at org.apache.ivy.plugins.repository.ssh.SshResource.resolve(SshResource.java:101)
The line 108 in AbstractSsshBasedRepository contains this :
return SshCache.getInstance().getSession(host, port, user, userPassword, getKeyFile(),
getKeyFilePassword(), getPassFile(), isAllowedAgentUse());
getSession is a method which calls attemptAgentUse.
Does this explain why an attempt to load AgentProxyException happens at that time ?
Regards,
Antoine
On May 11, 2014, at 5:41 PM, Nicolas Lalevée <ni...@hibnet.org> wrote:
> Hi,
>
> I need some help to understand a bug around classloading (nothing that particular to Ivy).
>
> I was looking into IVY-1471 [1] and I don't understand why it is failing that way. In the classpath there are both Ivy and Jsch, but not the optional jar related to managing the ssh agent via jsch. And it is failing because a class in that optional jar is not found. But I don't understand why the classloader is looking for it in the first place.
>
> The error is raised is AbstractSshBasedRepository, on the call of SshCache.getInstance() [2]. But as far as I can tell, nothing in the loading of the SshCache [3] class requires AgentProxyException. The class is only needed by the function SshCache#attemptAgentUse() [4], which will be called at runtime, if the end user actually want ssh agent support, in which case it would naturally fail. But here it fails very earlier.
>
> I have made a test case you can test with its build.xml, no IvyDE required there [5].
>
> Am I missing something ? Is there a special treatment for the loading of Exception classes ?
>
> Nicolas
>
> [1] https://issues.apache.org/jira/browse/IVY-1471
> [2] https://fisheye6.atlassian.com/browse/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/AbstractSshBasedRepository.java?hb=true#to108
> [3] https://fisheye6.atlassian.com/browse/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshCache.java?hb=true
> [4] https://fisheye6.atlassian.com/browse/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/ssh/SshCache.java?hb=true#to300
> [5] http://svn.apache.org/repos/asf/ant/ivy/ivyde/trunk/test/ssh-resolver/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org