编程语言
首页 > 编程语言> > java – 从maven-antrun-plugin调用ant脚本时出现IllegalAccessError

java – 从maven-antrun-plugin调用ant脚本时出现IllegalAccessError

作者:互联网

我刚刚将Maven从2.0.9更新到2.2.1,并且在运行maven构建时遇到以下异常:

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

build-jsps.xml ant脚本运行org.apache.jasper.JspC任务,以在maven正在构建的webapp中预编译JSP.这与Maven 2.0.9一起运行良好.

谷歌给了很多人提出类似的问题,但没有答案.有没有人碰到这个并知道如何解决这个问题?或者甚至只是为什么我得到了IllegalAccessError?

解决方法:

尝试明确地为“maven-antrun-plugin”设置ANT依赖性.

<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>

请注意,您可以在Maven的公共存储库中找到ANT的多个位置:

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

(2)是旧的,所以使用(1)代替

标签:java,maven-2,build-process,jsp,ant
来源: https://codeday.me/bug/20190701/1344446.html