I have an relatively old Grails app that uses ant to build the application. In the test server it build without any problems, but when I try to run it on my PC, I get a consistent error:
Caused by: jar:file:/C:/ant/apache-ant-1.8.0/lib/ant.jar!/org/apache/tools/ant/antlib.xml:37: Problem: failed to create task or type componentdef
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
at org.apache.tools.ant.UnknownElement.getNotFoundException(UnknownElement.java:484)
at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:416)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:160)
at org.apache.tools.ant.taskdefs.Antlib.execute(Antlib.java:146)
at org.apache.tools.ant.taskdefs.Definer.loadAntlib(Definer.java:432)
... 63 more
I have found that the error happens in the following part of the build:
<macrodef name="grails">
<attribute name="script"/>
<attribute name="args" default="" />
<sequential>
<grailsTask script="@{script}" args="@{args}" classpathref="grails.classpath">
<compileClasspath refid="compile.classpath"/>
<testClasspath refid="test.classpath"/>
<runtimeClasspath refid="app.classpath"/>
</grailsTask>
</sequential>
</macrodef>
If I comment out , there are no more errors.
For further refererence, here's the whole error dump:
G:\chp\src\hewittportlet\build.xml:131: The following error occurred while executing this line:
G:\chp\src\hewittportlet\build.xml:53: Unable to start Grails: java.lang.reflect.InvocationTargetExc
eption
at grails.ant.GrailsTask.runGrails(GrailsTask.java:124)
at grails.ant.GrailsTask.execute(GrailsTask.java:78)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
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.taskdefs.Sequential.execute(Sequential.java:68)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
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.taskdefs.MacroInstance.execute(MacroInstance.java:398)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
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:1360)
at org.apache.tools.ant.Project.executeTarget(Project.java:1329)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1212)
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)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.codehaus.groovy.grails.cli.support.GrailsBuildHelper.execute(GrailsBuildHelper.java:9
4)
at grails.ant.GrailsTask.runGrails(GrailsTask.java:113)
... 31 more
Caused by: java.lang.reflect.InvocationTargetException
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.codehaus.groovy.grails.cli.support.GrailsBuildHelper.execute(GrailsBuildHelper.java:8
8)
... 32 more
Caused by: The following error occurred while executing this line:
jar:file:/C:/ant/apache-ant-1.8.0/lib/ant.jar!/org/apache/tools/ant/antlib.xml:37: Problem: failed t
o create task or type componentdef
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:508)
at org.apache.tools.ant.taskdefs.Definer.loadAntlib(Definer.java:434)
at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:281)
at org.apache.tools.ant.ComponentHelper.checkNamespace(ComponentHelper.java:790)
at org.apache.tools.ant.ComponentHelper.getDefinition(ComponentHelper.java:260)
at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:237)
at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:216)
at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:414)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:160)
at groovy.util.AntBuilder.nodeCompleted(AntBuilder.java:186)
at groovy.util.BuilderSupport.doInvokeMethod(BuilderSupport.java:147)
at groovy.util.AntBuilder.doInvokeMethod(AntBuilder.java:154)
at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:64)
at org.codehaus.gant.GantBuilder.invokeMethod(GantBuilder.java:89)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at org.codehaus.gant.GantBinding.initializeGantBinding(GantBinding.groovy:109)
at org.codehaus.gant.GantBinding.this$4$initializeGantBinding(GantBinding.groovy)
at org.codehaus.gant.GantBinding$this$4$initializeGantBinding.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:
44)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:1
43)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:1
47)
at org.codehaus.gant.GantBinding.<init>(GantBinding.groovy:42)
at org.codehaus.groovy.grails.cli.GrailsScriptRunner.callPluginOrGrailsScript(GrailsScriptRu
nner.java:355)
at org.codehaus.groovy.grails.cli.GrailsScriptRunner.executeCommand(GrailsScriptRunner.java:
279)
at org.codehaus.groovy.grails.cli.GrailsScriptRunner.executeCommand(GrailsScriptRunner.java:
205)
... 37 more
Caused by: jar:file:/C:/ant/apache-ant-1.8.0/lib/ant.jar!/org/apache/tools/ant/antlib.xml:37: Proble
m: failed to create task or type componentdef
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
at org.apache.tools.ant.UnknownElement.getNotFoundException(UnknownElement.java:484)
at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:416)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:160)
at org.apache.tools.ant.taskdefs.Antlib.execute(Antlib.java:146)
at org.apache.tools.ant.taskdefs.Definer.loadAntlib(Definer.java:432)
... 63 more
Total time: 34 seconds