The groovy task will now be created using the tmp.groovy.groovyc class loader, which tries to avoid loading conflicting jars like antlr. It's important to execute the rootLoaderRef task once before the taskdef using the loaderref defined by the rootLoaderRef.
Solution 3: appropriate classpath set up
You may need to adjust your classpath setup to include the jars you are trying to use. For instance, if you have placed the groovy jar in your Ant LIB folder, then Groovy will be in Ant's root classloader. If you now wish to refer to an external library, e.g. a JDBC driver, you may need to place that library also in your Ant LIB folder so that it is visible in the same classLoader as Groovy. See the loaderref discussion above also.
No, both Solutions will not help if you have conflicting ant jars or common-logging jars somewhere. Solution 2 is able to solve much more difficult jar problems as long as your classpath is as clean as possible. if you want to be on the safe side you have to fork the javaVM which means you have to use the task like this: