IllegalAccessError when calling ant script from maven-antrun-plugin

I just upgraded Maven from 2.0.9 to 2.2.1, and I get the following exception when starting the maven build:

  INFO] [antrun: run {execution: precompile-jsp}]
 [INFO] Executing tasks

 default:

 jspc:
     [mkdir] Created dir: C: \ builds \ trunk \ webapps \ vyre_portlets \ WEB-INF \ jsp_src
 [INFO] ----------------------------------------------- -------------------------
 [ERROR] BUILD ERROR
 [INFO] ----------------------------------------------- -------------------------
 [INFO] An Ant BuildException has occured: The following error occurred while executing this line:
 C: \ unify \ trunk \ portlets \ build-jsps.xml: 87: The following error occurred while executing this line:
 C: \ unify \ trunk \ portlets \ build-jsps.xml: 7: java.lang.IllegalAccessError: tried to access method org.apache.tools.ant.launch.Locator.decodeUri (Ljava / lang / String;) Ljava / lang / String;  from class org.apache.tools.ant.AntClassLoader

In the build-jsps.xml ant script file, the org.apache.jasper.JspC task is executed to precompile the JSP in the webapp that maven creates. This works fine with Maven 2.0.9.

Google gives a ton of people asking similar questions, but no answers. Does anyone come across this and know how to solve this? Or even why am I getting IllegalAccessError?

+4
source share
2 answers

try setting the ANT dependency for "maven-antrun-plugin" explicitly.

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <executions> .... </executions> <dependencies> <dependency> <groupId>org.apache.ant</groupId> <artifactId>ant-nodeps</artifactId> <version>1.7.0</version> </dependency> </dependencies> </plugin> 

Please note that there are several places where you can find ANT in the Maven public repository:

  • <groupId>org.apache.ant</groupId>
  • <groupId>ant</groupId>

(2) is old, so use (1) instead

+3
source

In Maven 2.2.x, the versions of many plugins were updated, if you run the build with -X, you will see which version of antrun-plugin was used. If these are different versions, a different version of org.apache.tools.ant.launch.Locator may be used. Looking at the change history for Locator, the decodeUri method was introduced in Ant 1.7 and has been modified several times, although there is nothing that could cause obvioulsy problems.

Can you post a minimal pom and Ant configuration that shows an error? this will help diagnose the problem.

0
source

All Articles