Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Ant Task Troubleshooting

The Common Problem

very often user are talking that the groovy or groovyc tasks are failing with a ClassNotFoundException for the class GroovySourceAst

The Reason

somewhere you have a conflicting antlr in your classpath. This may be because you are using maven and one of this parts is polluting the classpath or you have a different antlr jar in your classpath somewhere.

Solution 1: groovy-all

Use the groovy-all-VERSION.jar from the groovy distribution and not the normal groovy jar. The groovy-all-VERSION.jar does already contain antlr and asm libs in a seperate namespace so there should be no conflict with other libs around.

Solution 2: using loaderef

Sometimes it's not possible to use the groovy-all-VERSION.jar, for example because you want to build groovy before creating the jar. In this case you have to add a loaderref to the task definition. But that alone will not help. You have to add the rootLoaderRef task to set this loader reference. For example:

The groovy task will now be created using the tmp.groovy.groovyc class loader, which tries to avoid loading conflicting jars like antlr.

All Solved?

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 conflicting jar problems as long as your classpath is as clean as possible. if you want to be on the save side you have to fork the javaVM which means you have to use the task like this:

References

  • No labels