[GRADLE-1212] ClassCastException when using dom4j 1.6.1 in an ant task Created: 08/Nov/10  Updated: 04/Jan/13  Resolved: 24/Nov/10

Status: Resolved
Project: Gradle
Affects Version/s: 0.9
Fix Version/s: 0.9-rc-3

Type: Bug
Reporter: Adam Murdoch Assignee: Hans Dockter
Resolution: Fixed Votes: 0


 Comments   
Comment by Andrew Phillips [ 09/Nov/10 ]

Checked a test case involving FlexUnit which causes the problem when run with rc-2. When run against a build from commit https://github.com/gradle/gradle/commit/ec171a6890c67f11b5b0b105288dbafac88a097a, the problem disappears. So this particular test case at least is fixed.

Comment by Michal Nowak [ 01/Mar/11 ]

Hi !

I am using Gradle 1.0-milestone-1. I am trying to run flex tests using flexunit ant tasks: flexUnitTasks-4.1.0_RC2-4. I am running whole thing under Windows 7. Unfortunately I keep getting the ClassCastException from dom4j library.

The ant target that I'm trying to execute from gradle looks like this:

<target name="test" depends="init">
<!-- Execute FlexUnit tests and publish reports -->
<flexunit
workingDir="${build.bin.dir}"
toDir="${build.report.dir}"
haltonfailure="false"
verbose="false"
localTrusted="true">
<source dir="${src.flex.dir}" />
<testSource dir="${test.flex.dir}">
<include name="**/*Test.as" />
</testSource>

<library dir="libs" />
<library dir="${flexunit.lib.dir}" />
</flexunit>

<!-- Generate readable JUnit-style reports -->
<junitreport todir="${build.report.dir}">
<fileset dir="${build.report.dir}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${build.report.dir}/html" />
</junitreport>
</target>

And the stacktrace looks like this:

org.gradle.api.tasks.LocationAwareTaskExecutionException: Build file 'C:\projects\petproject\petproject-flex-commons\petproject-flex-commons.gradle'
Execution failed for task ':petproject-flex-commons:test'.
at org.gradle.api.internal.tasks.DefaultTaskExecuter.executeActions(DefaultTaskExecuter.java:66)
at org.gradle.api.internal.tasks.DefaultTaskExecuter.execute(DefaultTaskExecuter.java:43)
at org.gradle.api.internal.project.taskfactory.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:32)
at org.gradle.api.internal.project.taskfactory.ExecutionShortCircuitTaskExecuter.execute(ExecutionShortCircuitTaskExecuter.java:50)
at org.gradle.api.internal.tasks.SkipTaskExecuter.doExecute(SkipTaskExecuter.java:57)
at org.gradle.api.internal.tasks.SkipTaskExecuter.execute(SkipTaskExecuter.java:35)
at org.gradle.api.internal.tasks.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:32)
at org.gradle.api.internal.AbstractTask.execute(AbstractTask.java:231)
at org.gradle.execution.DefaultTaskGraphExecuter.executeTask(DefaultTaskGraphExecuter.java:167)
at org.gradle.execution.DefaultTaskGraphExecuter.doExecute(DefaultTaskGraphExecuter.java:160)
at org.gradle.execution.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:78)
at org.gradle.execution.TaskNameResolvingBuildExecuter.execute(TaskNameResolvingBuildExecuter.java:113)
at org.gradle.execution.DelegatingBuildExecuter.execute(DelegatingBuildExecuter.java:54)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:153)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:107)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:75)
at org.gradle.launcher.RunBuildAction.execute(RunBuildAction.java:41)
at org.gradle.launcher.RunBuildAction.execute(RunBuildAction.java:27)
at org.gradle.launcher.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:209)
at org.gradle.launcher.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:193)
at org.gradle.launcher.Main.execute(Main.java:55)
at org.gradle.launcher.Main.main(Main.java:40)
at org.gradle.launcher.ProcessBootstrap.runNoExit(ProcessBootstrap.java:46)
at org.gradle.launcher.ProcessBootstrap.run(ProcessBootstrap.java:28)
at org.gradle.launcher.GradleMain.main(GradleMain.java:24)
Caused by: C:\projects\petproject\petproject-flex-commons\build.xml:19: java.util.concurrent.ExecutionException: Error parsing report.
at org.flexunit.ant.tasks.TestRun.run(Unknown Source)
at org.flexunit.ant.tasks.FlexUnitTask.execute(Unknown Source)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
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.gradle.api.tasks.ant.AntTarget.executeAntTarget(AntTarget.java:59)
at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:158)
at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:93)
at org.gradle.api.tasks.ant.AntTarget_Decorated.invokeMethod(Unknown Source)
at org.gradle.util.ReflectionUtil.invoke(ReflectionUtil.groovy:23)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$2.execute(AnnotationProcessingTaskFactory.java:131)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$2.execute(AnnotationProcessingTaskFactory.java:130)
at org.gradle.api.internal.tasks.DefaultTaskExecuter.executeActions(DefaultTaskExecuter.java:58)
... 24 more
Caused by: java.util.concurrent.ExecutionException: Error parsing report.
... 39 more
Caused by: Error parsing report.
at org.flexunit.ant.FlexUnitSocketThread.parseReport(Unknown Source)
at org.flexunit.ant.FlexUnitSocketThread.processTestReport(Unknown Source)
at org.flexunit.ant.FlexUnitSocketThread.parseInboundMessages(Unknown Source)
at org.flexunit.ant.FlexUnitSocketThread.call(Unknown Source)
Caused by: org.dom4j.DocumentException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory Nested exception: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.dom4j.DocumentHelper.parseText(DocumentHelper.java:278)
... 4 more

It looks like a class loader issue to me.

Please let me know if there is something else i can do to help resolving this.

Regards,
Michal Nowak

Generated at Wed Jun 30 11:49:51 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.