Multiple versions of ant detected path for junit | Selenium Forum
M
Posted on 26/10/2015
I am getting above error while running mvn compile. I am trying to run build.xml through maven using bat file like video 31.
I set up ANT_HOME directory in environment variable apache-ant-1.9.6.
and maven ant plugin 1.6.
-----------------------------------
Following errors are appearing
---------------------------------------
[exec] [echo] compiling...
[exec] [javac] C:\Users\skuruguntla\maven\MyMavenProject\build.xml:79: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[exec] [javac] Compiling 3 source files to C:\Users\skuruguntla\maven\MyMavenProject\build
[exec]
[exec] run:
[exec] [junit] WARNING: multiple versions of ant detected in path for junit
[exec] [junit] jar:file:/C:/DevFolder/apache-ant-1.9.6/lib/ant.jar!/org/apache/tools/ant/Project.class
[exec] [junit] and jar:file:/C:/Users/skuruguntla/.m2/repository/org/apache/ant/ant/1.8.1/ant-1.8.1.jar!/org/apache/tools/ant/Project.class
[exec] [junit] Running com.testing.GoogleTest
[exec] [junit] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 5.438 sec
[exec] [junit] Test com.testing.GoogleTest FAILED
[exec] [junit] Running com.testing.YahooTest
[exec] [junit] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 7.154 sec
[exec] [junit] Test com.testing.YahooTest FAILED
[exec] [junitreport] Processing C:\ash\TESTS-TestSuites.xml to C:\Users\SKURUG~1\AppData\Local\Temp\null20836417
[exec] [junitreport] Loading stylesheet jar:file:/C:/DevFolder/apache-ant-1.9.6/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl
[exec] [junitreport] Transform time: 1295ms
[exec] [junitreport] Deleting: C:\Users\SKURUG~1\AppData\Local\Temp\null20836417
[exec]
[exec] BUILD SUCCESSFUL
[exec] Total time: 24 seconds
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30.351 s
[INFO] Finished at: 2015-10-27T00:11:10+00:00
[INFO] Final Memory: 20M/222M
[INFO] ------------------------------------------------------------------------

C:\Users\skuruguntla\maven\MyMavenProject>
-----------------------------------------------------------------------
my build.xml as follows
--------------------------------------------------------------------------
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.testing</groupId>
<artifactId>MyMavenProject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>MyMavenProject</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.48.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>compile</phase>
<configuration>

<tasks name="runtheapp">
<!-- property name="compile_classpath" refid="maven.compile.classpath"/>
<property name="runtime_classpath" refid="maven.runtime.classpath"/>
<property name="test_classpath" refid="maven.test.classpath"/>
<property name="plugin_classpath" refid="maven.plugin.classpath"/>

<echo message="compile classpath: ${compile_classpath}"/>


<echo message="runtime classpath: ${runtime_classpath}"/>
<echo message="test classpath: ${test_classpath}"/>
<echo message="plugin classpath: ${plugin_classpath}"/-->

<ant antfile="build.xml"/>


<exec
dir="${basedir}"
executable="${basedir}/testrunner.bat"
failonerror="true">
<arg line=""/>
</exec>

</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

M
Replied on 27/10/2015

[quote:1ayswhrt]WARNING: multiple versions of ant detected in path for junit[/quote:1ayswhrt]

this is the problem. more then 1 ant jar file is lying in the folder. you are using maven so, delete .m2 repo.


M
Replied on 11/02/2016

What is the solution for this please?


M
Replied on 12/02/2016

delete your repo and run pom.xml again


M
Replied on 12/02/2016

I am running build.xml with ant and build.xml has jar files reference to maven repositories


M
Replied on 12/02/2016

I think this issue is seen more frequently for others also
Can you please give detailed document of how to resolve this please?


M
Replied on 12/02/2016

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE project>
-<project basedir="." default="usage" name="Module_8_Junit_Ant">
<!-- ========== Initialize Properties =================================== -->
<property environment="env"/> <property name="ws.home" value="${basedir}"/> <property name="ws.jars" value="${user.home}/.m2/repository/"/> <property name="test.dest" value="${ws.home}/build"/> <property name="test.src" value="${ws.home}/src"/> <property name="test.reportsDir" value="D:/Selenium_Practice/rep"/> -<path id="testcase.path"> <pathelement location="${test.dest}"/> -<fileset dir="${ws.jars}"> <include name="*.jar"/> </fileset> </path>
<!--target name="start-selenium-server"> <java jar="${ws.home}/lib/selenium-server.jar"/> </target-->
-<target name="setClassPath" unless="test.classpath"> -<path id="classpath_jars"> <fileset dir="${ws.jars}" includes="**/*.jar"/> </path> <pathconvert refid="classpath_jars" property="test.classpath" pathsep=":"/> </target> -<target name="init" depends="setClassPath"> -<tstamp> <format property="start.time" pattern="MM/dd/yyyy hh:mm aa"/> </tstamp> -<condition value="${env.ANT_HOME}/bin/ant.bat" property="ANT" else="${env.ANT_HOME}/bin/ant"> <os family="windows"/> </condition> </target>
<!-- all -->
<target name="all"> </target>
<!-- clean -->
-<target name="clean"> <delete dir="${test.dest}"/> </target>
<!-- compile -->
-<target name="compile" depends="init, clean"> -<delete quiet="true" includeemptydirs="true"> <fileset dir="${test.dest}" includes="**/*"/> </delete> <echo message="making directory..."/> <mkdir dir="${test.dest}"/> <echo message="classpath------: ${test.classpath}"/> <echo message="compiling..."/> <javac classpath="${test.classpath}" target="1.8" srcdir="${test.src}" destdir="${test.dest}" debug="true"> </javac> </target>
<!-- build -->
<target name="build" depends="init"> </target> -<target name="usage"> <echo> ant run will execute the test </echo> </target> -<path id="test.run"> <fileset dir="${ws.jars}" includes="**/*.jar"/> </path> -<target name="run"> -<delete quiet="true" includeemptydirs="true"> <fileset dir="${test.reportsDir}" includes="**/*"/> </delete> <java spawn="true" fork="true" jar="${ws.jars}"/> -<junit fork="yes" printsummary="yes" haltonfailure="no"> <classpath refid="test.run"/>
<!-- <classpath ="${test.classpath}"/> -->
-<batchtest fork="true" todir="${test.reportsDir}"> -<fileset dir="${test.dest}">
<!--include name="tests/LoginTest.class" /> <include name="tests/Parameterized_Test.class" /> <include name="tests/TestApplication.class" /-->
<include name="com/testing/GoogleTest.class"/> <include name="com/testing/YahooTest.class"/> </fileset> </batchtest> <formatter type="xml"/> <classpath refid="testcase.path"/> </junit> -<junitreport todir="${test.reportsDir}"> -<fileset dir="${test.reportsDir}"> <include name="TEST-*.xml"/> </fileset> <report todir="${test.reportsDir}"/> </junitreport> </target> </project>


M
Replied on 12/02/2016

[quote="muralikrishnapb@gmail.com":7bpmsye7]I think this issue is seen more frequently for others also
Can you please give detailed document of how to resolve this please?[/quote:7bpmsye7]

i am telling you how to solve the issue delete the .m2/repository and run pom.xml again so the jar files can be downloaded again and after that run build.xml


M
Replied on 12/02/2016

Sure Thankyou, i need to delete repository and do mvn package right to run pom.xml?


M
Replied on 12/02/2016

do a [color=#FF0000:1cg8qyvf]mvn test[/color:1cg8qyvf] it will run your project once and after that you can use ant and build.xml to run it.


M
Replied on 12/02/2016

I have done following steps but it didnt work

1) deleted .m2/repository folder
2)
mvn compile
mvn package
mvn test

mvn package and mvn tests were opening yahoo.com and google.com and working fine

then tried in ant

ant clean
ant compile
ant run

this time that multiple versions of ant detected path for junit is not seen

but I am seeing empty browsers and tests were failing

com.google.common.collect.Multimaps.transformValues(Lcom/google/common/collect/ListMultimap;Lcom/google/common/base/Function;)Lcom/google/common/collect/ListMultimap;

java.lang.NoSuchMethodError: com.google.common.collect.Multimaps.transformValues(Lcom/google/common/collect/ListMultimap;Lcom/google/common/base/Function;)Lcom/google/common/collect/ListMultimap;
at com.google.common.net.MediaType.computeToString(MediaType.java:751)
at com.google.common.net.MediaType.toString(MediaType.java:741)
at org.openqa.selenium.remote.http.JsonHttpCommandCodec.encode(JsonHttpCommandCodec.java:232)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:139)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.execute(NewProfileExtensionConnection.java:160)
at org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor.execute(FirefoxDriver.java:380)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:216)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:207)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
at com.testing.GoogleTest.testGoogle(GoogleTest.java:20)


M
Replied on 12/02/2016

try this

http://stackoverflow.com/questions/25088899/selenium-webdriver-throws-exception-when-trying-to-run-via-ant


M
Replied on 13/02/2016

Hi Ashish

I am not able to see any such duplicate jar files , Can you please help me resolve this?
If you need I can give access to my machine.

Thanks in Advance
Regards
Bala


M
Replied on 13/02/2016

send me the project first.


M
Replied on 13/02/2016

Hi Ashish

Thanks for your quick reply

I am able to resolve the issue, but unable to run the ant file using mvn compile ( running build.xml from pom.xml)

I have deleted the below jar file from repsoitory
C:\Users\bpaithar.ORADEV\.m2\repository\com\google\collections\google-collections\1.0\google-collections-1.0.jar

and did ant clean compile run -> tests passed

on doing mvn compile -> maven is downloading the deleted jar file above in repository and hence tests are failing with same issue.
How do i tell maven(pom.xml) not to download that jar file? Can you please help on this

Regards
Bala


M
Replied on 13/02/2016

get rid of google-collections-1.0.jar dependency in pom.xml.


M
Replied on 13/02/2016

I am not able to do that , can you please tell me how to get rid of it, please


M
Replied on 13/02/2016

watch video about maven its explained there.


M
Replied on 13/02/2016

Module 31? I didnt see anything there


M
Replied on 14/02/2016

no watch maven module 9.


M
Replied on 08/09/2016

I too faced the same issue, even when adding the exclusion of google-collections in POM.xml and ran mvn compile it is again downloading it. Please help
Here is my pom.xml, please correct me if it is wrong i have added exclusion in each dependency and alsi individual exclusion:

<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.testing</groupId>
<artifactId>MyMavenProject1Kalyan</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>MyMavenProject1Kalyan</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<exclusions>
<exclusion>
<artifactId>google-collections</artifactId>
<groupId>com.google.collections</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.52.0</version>
<exclusions>
<exclusion>
<artifactId>google-collections</artifactId>
<groupId>com.google.collections</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.collections</groupId>
<artifactId>google-collections</artifactId>
<version>1.0</version>
<exclusions>
<exclusion>
<artifactId>google-collections</artifactId>
<groupId>com.google.collections</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

</project>