Having an issue with doing ant builds via command line due to a maven failure. I can build in eclipse without issue, but when trying to execute via command line, Maven chokes and returns the following error:
java.lang.NoSuchMethodError: org.apache.maven.artifact.ant.DependenciesTask.setPathType(Ljava/lang/String;)
I have the environment variables M2 M2_HOME and JAVA_HOME set. Everything seems to be as it should be but I can't seem to figure out where eclipse is filling in the blanks, when it comes to any dependency methods or libraries.
POM file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.company.webapp</groupId>
<artifactId>V6</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>company Web Site</name>
<properties>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.source>1.6</maven.compiler.source>
<spring.version>3.2.4.RELEASE</spring.version>
<servlet-api.version>3.0.1</servlet-api.version>
<jaxb-api.version>2.1</jaxb-api.version>
<spring-hateoas.version>0.7.0.RELEASE</spring-hateoas.version>
<junit.version>4.11</junit.version>
<spring-mvctest.version>1.0.0.M2</spring-mvctest.version>
<httpclient.version>4.3.3</httpclient.version>
<jstl.version>1.2</jstl.version>
<jersey-client.version>1.8</jersey-client.version>
<jackson-mapper-asl.version>1.9.13</jackson-mapper-asl.version>
<jackson-core.version>2.4.0</jackson-core.version>
<jackson-databind.version>2.4.3</jackson-databind.version>
<logback-spring.version>1.0-SNAPSHOT</logback-spring.version>
<logback-classic.version>1.0.13</logback-classic.version>
<slf4j.version>1.7.5</slf4j.version>
<company-ws-util.version>1.1.5-SNAPSHOT</company-ws-util.version>
<company-util-misc.version>1.2.31-SNAPSHOT</company-util-misc.version>
<company-util-cache.version>1.4.7-SNAPSHOT</company-util-cache.version>
<java-mail.version>1.4</java-mail.version>
<commons-lang3.version>3.1</commons-lang3.version>
</properties>
<dependencies>
<!-- Spring 3 dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<!-- Java Mail API -->
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>${java-mail.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet-api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey-client.version}</version>
</dependency>
<!-- Jackson JSON Mapper -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>${jackson-mapper-asl.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-databind.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson-core.version}</version>
</dependency>
<!-- Internal Libraries -->
<dependency>
<groupId>com.company.util</groupId>
<artifactId>company-util-misc</artifactId>
<version>${company-util-misc.version}</version>
</dependency>
<dependency>
<groupId>com.company.ws.util</groupId>
<artifactId>company-ws-util</artifactId>
<version>${company-ws-util.version}</version>
</dependency>
<dependency>
<groupId>com.company.util</groupId>
<artifactId>company-util-cache</artifactId>
<version>${company-util-cache.version}</version>
</dependency>
<!-- Logging -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback-classic.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- Test scope -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<version>${junit.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${basedir}/build/@mvn@/mvn.build.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<webResources>
<resource>
<directory>${basedir}/build/${VERSION}</directory>
</resource>
</webResources>
<webappDirectory>${basedir}/build/${VERSION}</webappDirectory>
</configuration>
</plugin>
</plugins>
<directory>build/target</directory>
<finalName>${WARFILE}</finalName>
</build>
</project>
Full error stack:
[echo] MVN BUILD (MAVEN):
[echo] --------------------------
[mkdir] Skipping C:\"PATH"\build\@mvn@ because it already exists.
[propertyfile] Updating property file: C:\"PATH"\build\@mvn@\mvn.build.properties
Property "quickbuild" has not been set
[echo] Executing maven build on Developer machine (other machine)
parsing buildfile jar:file:/C:/Apps/ANT/apache-ant-1.9.5/lib/maven-artifact-ant-2.0.4-dep.jar!/org/apache/maven/artifact/ant/antlib.xml with URI = jar:file:/C:/Apps/ANT/apache-ant-1.9.5/lib/maven-artifact-ant-2.0.4-dep.jar!/org/apache/maven/artifact/ant/antlib.xml from a zip file
[antcall] Exiting C:\"PATH"\build.xml.
BUILD FAILED
C:\"PATH"\build.xml:349: The following error occurred while executing this line:
C:\"PATH"\build.xml:279: The following error occurred while executing this line:
C:\"PATH"\ant\imports\mvn.xml:46: Maven sub-build has failed! Error in trycatch block:
EXCEPTION BEGIN
C:\"PATH"\ant\imports\mvn.xml:38: java.lang.NoSuchMethodError: org.apache.maven.artifact.ant.DependenciesTask.setPathType(Ljava/lang/String;)V{line.separator}EXCEPTION END
at org.apache.tools.ant.taskdefs.Exit.execute(Exit.java:164)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at net.sf.antcontrib.logic.TryCatchTask$CatchBlock.execute(TryCatchTask.java:137)
at net.sf.antcontrib.logic.TryCatchTask.execute(TryCatchTask.java:225)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at net.sf.antcontrib.logic.IfTask.execute(IfTask.java:217)
at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:155)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:396)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at net.sf.antcontrib.logic.IfTask.execute(IfTask.java:197)
at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:155)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:441)
at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.Main.runBuild(Main.java:853)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
As mentioned in the comments, there is a difference between the version of the Maven Ant tasks used in Eclipse versus the one used on the command line. Eclipse seems to be using a newer version of this library in which the method DependenciesTask.setPathType(String)
exists whereas the command line is relying on an older version.
You may be able to get more information on which version of the Ant tasks Eclipse is using by checking the preferences page. Try navigating to Window -> Preferences -> Ant -> Runtime and see Classpath tab for external libraries.
On the other hand, from the output of the Ant build:
[echo] Executing maven build on Developer machine (other machine)
parsing buildfile jar:file:/C:/Apps/ANT/apache-ant-1.9.5/lib/maven-artifact-ant-2.0.4-dep.jar!/org/apache/maven/artifact/ant/antlib.xml with URI = jar:file:/C:/Apps/ANT/apache-ant-1.9.5/lib/maven-artifact-ant-2.0.4-dep.jar!/org/apache/maven/artifact/ant/antlib.xml from a zip file
the command line is obviously using version 2.0.4 which is located in the lib folder of the Ant home directory. Checking this page, the latest version is 2.1.3 which does contain the missing method. So it would make sense to update the version in the Ant lib directory to be the latest one (check the download link on the project page).
You can always run maven against same settings.xml which you are using for eclipse(Use "-s ")
We can get more description by running maven in debug move : Use "-X" while running maven.
Okay, here's the exact problem and solution in detail...
I was confused over a couple things. Originally, I wasn't clear that maven-ant-tasks and maven-artifact-ant were the same library and I thought that I needed to install maven-ant-tasks, but that was cleared up with original responses. Secondly, when researching how to update (or install) maven-ant-tasks I found out that this was already happening in my configuration, and since the correct methods appeared as early as 2.1.2, I could see that the following configuration in our system was correct, and that the problem shouldn't be happening
My project config code:
<taskdef resource="org/apache/maven/artifact/ant/antlib.xml" uri="antlib:org.apache.maven.artifact.ant">
<classpath>
<pathelement location="${basedir}/ant/lib/maven-ant-tasks-2.1.3.jar"/>
</classpath>
</taskdef>
The documentation supports this here: http://maven.apache.org/ant-tasks/installation.html (slightly different code but same purpose and result)
Alas, the problem was still occurring... After a -verbose dump and compare of both eclipse build output as well as command-line output, I could see that the only difference was that the command line was trying to call both files, and when it did, only a couple of the needed methods were loading.
After looking in the ant directories for eclipse, I noticed that the maven-ant-tasks library was simply not there, so I tried removing it from my own install and Voila!... I would have expected a polymorphic result, but apparently it doesn't work that way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With