views:

764

answers:

4

I just updated Maven from 2.0.9 to 2.2.1 and I'm getting the following exception when running a 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

The build-jsps.xml ant script runs the org.apache.jasper.JspC task to precompile JSP in the a webapp that maven is building. This was working fine with Maven 2.0.9.

Google gives a bunch of people asking similar questions, but no answers. Has anyone run into this and knows how to resolve this? Or even just why I'm getting the IllegalAccessError?

A: 

In Maven 2.2.x, the versions of many of the plugins have been updated, if you run the build with -X, you'll see what version of the antrun-plugin has been used. If these are different versions, it may be using a different version of org.apache.tools.ant.launch.Locator. Looking at the change history for Locator, the decodeUri method was introduced in Ant 1.7 and has been tweaked a few times, though nothing that would obvioulsy cause the problem.

Can you post a minimal pom and ant configuration that shows the error? this would help diagnose the problem.

Rich Seller
+2  A: 

try to set 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>

Note that there are multiple places where you can find ANT in Maven's public repository:

  1. <groupId>org.apache.ant</groupId>
  2. <groupId>ant</groupId>

(2) is the old one so use (1) instead

mtim
Eureka! I've found out why this wasn't working for me. The ant call that failed was in a subproject of a project that also does ant calls. It appears maven only sets up the dependencies for a plugin once per execution, so you have to do it in the first usage in the build.
Sindri Traustason
+1  A: 

Thanks mtim -- works beautifully!

Kalle
It doesn't work for me at all. Did you make any other changes than what mtim suggested?Did you have exactly the same issue?
Sindri Traustason
A: 

I had a similar issue and this solution worked for me as well.

menapole
This should have been a comment and/or an upvote. Please don't post comments as answers :)
BalusC