You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-user@ant.apache.org by "Loehr, Ruel" <rl...@pointserve.com> on 2007/01/22 20:43:00 UTC

classcast exception when attempting to use cachepath task

Hi.

 

I'm having a problem using the cachepath task.  I receive a class cast
exception when I define it.  I've researched the problem but cannot have
not found a solution yet.

 

My ivy.xml looks like this:

 

<ivy-module version="1.0">

    <info organisation="pointserve" module="eso"/>

    <dependencies>

        <dependency org="xdoclet" name="xdoclet-ejb-module" rev="1.2.3"
conf="xdoclet"/>

        <dependency org="xdoclet" name="xdoclet" rev="1.2.3"
conf="xdoclet"/>

        <dependency org="xjavadoc" name="xjavadoc" rev="1.1"
conf="xdoclet"/>     

        <dependency org="commons-collections" name="commons-collections"
rev="2.0" conf="xdoclet"/>             

        <dependency org="commons-logging" name="commons-logging"
rev="1.0.4" conf="xdoclet"/>                     

        <dependency org="xdoclet" name="xdoclet-jboss-module"
rev="1.2.3" conf="xdoclet"/>                     

        <dependency org="xdoclet" name="xdoclet-jmx-module" rev="1.2.3"
conf="xdoclet"/>                             

        <dependency org="xdoclet" name="xdoclet-web-module" rev="1.2.3"
conf="xdoclet"/>                                     

        <dependency org="xdoclet" name="xdoclet-java-module" rev="1.2.3"
conf="xdoclet"/>                                             

    </dependencies>

</ivy-module>

 

The dependencies get downloaded, no big issue there.

 

In my build.xml I try to execute this task:

    <ivy-cachepath pathid="xDocletClasspath" conf="xdoclet" />

 

And get the following stack trace:

 

BUILD FAILED

C:\projects\snm\build\task-paths.xml:5: java.lang.ClassCastException:
fr.jayasof

t.ivy.DefaultModuleDescriptor

        at org.apache.tools.ant.Task.perform(Task.java:373)

        at org.apache.tools.ant.Target.execute(Target.java:341)

        at org.apache.tools.ant.Target.performTasks(Target.java:369)

        at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)

        at org.apache.tools.ant.Project.executeTarget(Project.java:1185)

        at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe

cutor.java:40)

        at
org.apache.tools.ant.Project.executeTargets(Project.java:1068)

        at org.apache.tools.ant.Main.runBuild(Main.java:668)

        at org.apache.tools.ant.Main.startAnt(Main.java:187)

        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)

        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)

Caused by: java.lang.ClassCastException:
fr.jayasoft.ivy.DefaultModuleDescriptor

 

        at
fr.jayasoft.ivy.ant.IvyTask.getConfsToResolve(IvyTask.java:130)

        at fr.jayasoft.ivy.ant.IvyTask.ensureResolved(IvyTask.java:119)

        at
fr.jayasoft.ivy.ant.IvyPostResolveTask.prepareAndCheck(IvyPostResolve

Task.java:87)

        at
fr.jayasoft.ivy.ant.IvyCachePath.execute(IvyCachePath.java:42)

        at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)

        at org.apache.tools.ant.Task.perform(Task.java:364)

        ... 10 more

--- Nested Exception ---

java.lang.ClassCastException: fr.jayasoft.ivy.DefaultModuleDescriptor

        at
fr.jayasoft.ivy.ant.IvyTask.getConfsToResolve(IvyTask.java:130)

        at fr.jayasoft.ivy.ant.IvyTask.ensureResolved(IvyTask.java:119)

        at
fr.jayasoft.ivy.ant.IvyPostResolveTask.prepareAndCheck(IvyPostResolve

Task.java:87)

        at
fr.jayasoft.ivy.ant.IvyCachePath.execute(IvyCachePath.java:42)

        at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)

        at org.apache.tools.ant.Task.perform(Task.java:364)

        at org.apache.tools.ant.Target.execute(Target.java:341)

        at org.apache.tools.ant.Target.performTasks(Target.java:369)

        at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)

        at org.apache.tools.ant.Project.executeTarget(Project.java:1185)

        at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe

cutor.java:40)

        at
org.apache.tools.ant.Project.executeTargets(Project.java:1068)

        at org.apache.tools.ant.Main.runBuild(Main.java:668)

        at org.apache.tools.ant.Main.startAnt(Main.java:187)

        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)

        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)

 

 

The key error is:

 

java.lang.ClassCastException: fr.jayasoft.ivy.DefaultModuleDescriptor

        at
fr.jayasoft.ivy.ant.IvyTask.getConfsToResolve(IvyTask.java:130)

 

I pulled up the source code, but nothing stands out to me......Any
ideas?  The old forums are dead and I am stumped.

 

Ruel Loehr

Configuration Management

 

Pointserve, Inc.

110 Wild Basin Road

Suite 300

Austin, Texas 78746

O: 512.617.5314

F: 512.617.0466

 


Re: classcast exception when attempting to use cachepath task

Posted by Steve Loughran <st...@apache.org>.
Xavier Hanin wrote:
> On 1/22/07, Loehr, Ruel <rl...@pointserve.com> wrote:
>>
>> Hi.
> 
> 
> Hi
> 
> I'm having a problem using the cachepath task.  I receive a class cast
>> exception when I define it.  I've researched the problem but cannot have
>> not found a solution yet.
> 
> 
> You're problem is pretty strange, but I would bet it's a classloader
> problem. Indeed here is line 130:
>        ModuleDescriptor reference = (ModuleDescriptor)
> getResolvedDescriptor(org, module, strict);
> 
> And the CCE indicate that the class of the object is
> DefaultModuleDescriptor, which implements ModuleDescriptor. So it's
> presumably because the ModuleDescriptor interface has not been loaded with
> the same classloader as the class DefaultModuleDescriptor. How do you load
> Ivy in ant? Do you use a taskdef with a special classpath, or do you put 
> Ivy
> in your ant lib directory? And do you call ant with some kind of recursive
> feature, like subant or ant tasks? If it is the case try to do something
> very simple (like a single build file with ivy.jar in ant lib directory
> only) to see if the problem comes from here or not. And if you manage to
> identify the problem, please add an bug in JIRA.
> 

If you declare types and tasks in separatate <taskdef> and <typedef> 
calls, you should force both into the same classloader instance by 
setting loaderRef="some-shared-string" in both declarations. otherwise 
ant loads them into differenct classloaders, even if the classpath is 
identical

Re: classcast exception when attempting to use cachepath task

Posted by Xavier Hanin <xa...@gmail.com>.
On 1/22/07, Loehr, Ruel <rl...@pointserve.com> wrote:
>
> Hi.


Hi

I'm having a problem using the cachepath task.  I receive a class cast
> exception when I define it.  I've researched the problem but cannot have
> not found a solution yet.


 You're problem is pretty strange, but I would bet it's a classloader
problem. Indeed here is line 130:
        ModuleDescriptor reference = (ModuleDescriptor)
getResolvedDescriptor(org, module, strict);

And the CCE indicate that the class of the object is
DefaultModuleDescriptor, which implements ModuleDescriptor. So it's
presumably because the ModuleDescriptor interface has not been loaded with
the same classloader as the class DefaultModuleDescriptor. How do you load
Ivy in ant? Do you use a taskdef with a special classpath, or do you put Ivy
in your ant lib directory? And do you call ant with some kind of recursive
feature, like subant or ant tasks? If it is the case try to do something
very simple (like a single build file with ivy.jar in ant lib directory
only) to see if the problem comes from here or not. And if you manage to
identify the problem, please add an bug in JIRA.

Xavier

My ivy.xml looks like this:
>
>
>
> <ivy-module version="1.0">
>
>     <info organisation="pointserve" module="eso"/>
>
>     <dependencies>
>
>         <dependency org="xdoclet" name="xdoclet-ejb-module" rev="1.2.3"
> conf="xdoclet"/>
>
>         <dependency org="xdoclet" name="xdoclet" rev="1.2.3"
> conf="xdoclet"/>
>
>         <dependency org="xjavadoc" name="xjavadoc" rev="1.1"
> conf="xdoclet"/>
>
>         <dependency org="commons-collections" name="commons-collections"
> rev="2.0" conf="xdoclet"/>
>
>         <dependency org="commons-logging" name="commons-logging"
> rev="1.0.4" conf="xdoclet"/>
>
>         <dependency org="xdoclet" name="xdoclet-jboss-module"
> rev="1.2.3" conf="xdoclet"/>
>
>         <dependency org="xdoclet" name="xdoclet-jmx-module" rev="1.2.3"
> conf="xdoclet"/>
>
>         <dependency org="xdoclet" name="xdoclet-web-module" rev="1.2.3"
> conf="xdoclet"/>
>
>         <dependency org="xdoclet" name="xdoclet-java-module" rev="1.2.3"
> conf="xdoclet"/>
>
>     </dependencies>
>
> </ivy-module>
>
>
>
> The dependencies get downloaded, no big issue there.
>
>
>
> In my build.xml I try to execute this task:
>
>     <ivy-cachepath pathid="xDocletClasspath" conf="xdoclet" />
>
>
>
> And get the following stack trace:
>
>
>
> BUILD FAILED
>
> C:\projects\snm\build\task-paths.xml:5: java.lang.ClassCastException:
> fr.jayasof
>
> t.ivy.DefaultModuleDescriptor
>
>         at org.apache.tools.ant.Task.perform(Task.java:373)
>
>         at org.apache.tools.ant.Target.execute(Target.java:341)
>
>         at org.apache.tools.ant.Target.performTasks(Target.java:369)
>
>         at
> org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
>
>         at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
>
>         at
> org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe
>
> cutor.java:40)
>
>         at
> org.apache.tools.ant.Project.executeTargets(Project.java:1068)
>
>         at org.apache.tools.ant.Main.runBuild(Main.java:668)
>
>         at org.apache.tools.ant.Main.startAnt(Main.java:187)
>
>         at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
>
>         at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
>
> Caused by: java.lang.ClassCastException:
> fr.jayasoft.ivy.DefaultModuleDescriptor
>
>
>
>         at
> fr.jayasoft.ivy.ant.IvyTask.getConfsToResolve(IvyTask.java:130)
>
>         at fr.jayasoft.ivy.ant.IvyTask.ensureResolved(IvyTask.java:119)
>
>         at
> fr.jayasoft.ivy.ant.IvyPostResolveTask.prepareAndCheck(IvyPostResolve
>
> Task.java:87)
>
>         at
> fr.jayasoft.ivy.ant.IvyCachePath.execute(IvyCachePath.java:42)
>
>         at
> org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
>
>         at org.apache.tools.ant.Task.perform(Task.java:364)
>
>         ... 10 more
>
> --- Nested Exception ---
>
> java.lang.ClassCastException: fr.jayasoft.ivy.DefaultModuleDescriptor
>
>         at
> fr.jayasoft.ivy.ant.IvyTask.getConfsToResolve(IvyTask.java:130)
>
>         at fr.jayasoft.ivy.ant.IvyTask.ensureResolved(IvyTask.java:119)
>
>         at
> fr.jayasoft.ivy.ant.IvyPostResolveTask.prepareAndCheck(IvyPostResolve
>
> Task.java:87)
>
>         at
> fr.jayasoft.ivy.ant.IvyCachePath.execute(IvyCachePath.java:42)
>
>         at
> org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
>
>         at org.apache.tools.ant.Task.perform(Task.java:364)
>
>         at org.apache.tools.ant.Target.execute(Target.java:341)
>
>         at org.apache.tools.ant.Target.performTasks(Target.java:369)
>
>         at
> org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
>
>         at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
>
>         at
> org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe
>
> cutor.java:40)
>
>         at
> org.apache.tools.ant.Project.executeTargets(Project.java:1068)
>
>         at org.apache.tools.ant.Main.runBuild(Main.java:668)
>
>         at org.apache.tools.ant.Main.startAnt(Main.java:187)
>
>         at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
>
>         at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
>
>
>
>
>
> The key error is:
>
>
>
> java.lang.ClassCastException: fr.jayasoft.ivy.DefaultModuleDescriptor
>
>         at
> fr.jayasoft.ivy.ant.IvyTask.getConfsToResolve(IvyTask.java:130)
>
>
>
> I pulled up the source code, but nothing stands out to me......Any
> ideas?  The old forums are dead and I am stumped.
>
>
>
> Ruel Loehr
>
> Configuration Management
>
>
>
> Pointserve, Inc.
>
> 110 Wild Basin Road
>
> Suite 300
>
> Austin, Texas 78746
>
> O: 512.617.5314
>
> F: 512.617.0466
>
>
>
>
>