Maven Ant Tasks
  1. Maven Ant Tasks
  2. MANTTASKS-203

java.lang.ClassCastException: org.codehaus.plexus.DefaultPlexusContainer cannot be cast to org.codehaus.plexus.PlexusContainer

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 2.1.0, 2.1.1
    • Fix Version/s: None
    • Component/s: dependencies task
    • Labels:
      None
    • Environment:
      Apache Ant version 1.8.1
      Linux
      java version "1.6.0_21"
      Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
      Java HotSpot(TM) 64-Bit Server VM (build 17.0-b16, mixed mode)
    • Testcase included:
      yes
    • Number of attachments :
      1

      Description

      Running "ant test test2" for the submitted test results in a ClassCastException:

      java.lang.ClassCastException: org.codehaus.plexus.DefaultPlexusContainer cannot be cast to org.codehaus.plexus.PlexusContainer
      at org.apache.maven.artifact.ant.AbstractArtifactTask.getContainer(AbstractArtifactTask.java:481)
      at org.apache.maven.artifact.ant.AbstractArtifactTask.lookup(AbstractArtifactTask.java:456)
      at org.apache.maven.artifact.ant.AbstractArtifactTask.initSettings(AbstractArtifactTask.java:289)
      at org.apache.maven.artifact.ant.AbstractArtifactTask.execute(AbstractArtifactTask.java:717)
      at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
      at org.apache.tools.ant.Task.perform(Task.java:348)
      at org.apache.tools.ant.Target.execute(Target.java:390)
      at org.apache.tools.ant.Target.performTasks(Target.java:411)
      at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1397)
      at org.apache.tools.ant.Project.executeTarget(Project.java:1366)
      at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
      at org.apache.tools.ant.Project.executeTargets(Project.java:1249)
      at org.apache.tools.ant.Main.runBuild(Main.java:801)
      at org.apache.tools.ant.Main.startAnt(Main.java:218)
      at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
      at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

      1. build.xml
        0.7 kB
        Thomas Scheffler

        Activity

        Hide
        Arturas Gusevas added a comment -

        I had the same issue. The problem occurs, when mvn-init target will be called twice. You can solve it using the "unless" attribute. For example:

        <target name="mvn-init" unless="mvn-init.called">
            <path id="maven-ant-tasks.classpath" path="maven-ant-tasks-2.1.1.jar"/>
            <typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="antlib:org.apache.maven.artifact.ant" classpathref="maven-ant-tasks.classpath"/>
            <artifact:dependencies pathId="application.jars" filesetId="dependency.fileset" versionsId="dependency.versions">
                <dependency groupId="javax.servlet" artifactId="servlet-api" version="2.4" scope="provided"/>
            </artifact:dependencies>
            
            <property name="mvn-init.called" value="true" />
        </target>
        
        <target name="test" depends="mvn-init"></target>
        <target name="test2" depends="mvn-init"></target>
        
        Show
        Arturas Gusevas added a comment - I had the same issue. The problem occurs, when mvn-init target will be called twice. You can solve it using the "unless" attribute. For example: <target name= "mvn-init" unless= "mvn-init.called" > <path id= "maven-ant-tasks.classpath" path= "maven-ant-tasks-2.1.1.jar" /> <typedef resource= "org/apache/maven/artifact/ant/antlib.xml" uri= "antlib:org.apache.maven.artifact.ant" classpathref= "maven-ant-tasks.classpath" /> <artifact:dependencies pathId= "application.jars" filesetId= "dependency.fileset" versionsId= "dependency.versions" > <dependency groupId= "javax.servlet" artifactId= "servlet-api" version= "2.4" scope= "provided" /> </artifact:dependencies> <property name= "mvn-init.called" value= "true" /> </target> <target name= "test" depends= "mvn-init" > </target> <target name= "test2" depends= "mvn-init" > </target>

          People

          • Assignee:
            Unassigned
            Reporter:
            Thomas Scheffler
          • Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: