0

I have added all dependencies(my project ,junit,etc) and surefire plugin. so it is executing successfully in eclipse but when run through command prompt it throws error. below is the attached screenshot. and the pom.xml file . embeeded maven settings in eclipse works.maven location is also getting recognised from command prompt BUILD FAILURE ERROR

<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.selenium</groupId>
  <artifactId>test</artifactId>
  <version>0.0.1-SNAPSHOT</version>

 <dependencies>

 <!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>6.11</version>
    <scope>test</scope>
</dependency>


<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server 
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-server</artifactId>
    <version>2.53.1</version>
</dependency>
-->
<!-- https://mvnrepository.com/artifact/com.codeborne/phantomjsdriver -->
<dependency>
    <groupId>com.codeborne</groupId>
    <artifactId>phantomjsdriver</artifactId>
    <version>1.3.0</version>
</dependency>



  <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>2.53.1</version>
</dependency>

  <!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.17</version>
</dependency>



   <!-- https://mvnrepository.com/artifact/com.sun.mail/javax.mail -->
<dependency>
    <groupId>com.sun.mail</groupId>
    <artifactId>javax.mail</artifactId>
    <version>1.5.6</version>
</dependency>
  <!-- https://mvnrepository.com/artifact/org.uncommons/reportng -->
<dependency>
    <groupId>org.uncommons</groupId>
    <artifactId>reportng</artifactId>
    <version>1.1.4</version>
    <scope>test</scope>
</dependency>
  <!-- https://mvnrepository.com/artifact/com.google.inject/guice -->
<dependency>
    <groupId>com.google.inject</groupId>
    <artifactId>guice</artifactId>
    <version>4.1.0</version>
</dependency>

  <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>test</scope>
</dependency>

   <!-- Dependency for POI API -->
   <!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>3.17</version>
</dependency>
  <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>3.17</version>
</dependency>

  </dependencies>


    <build>
  <plugins>
  <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.18.1</version>
                <configuration>
                    <testFailureIgnore> false </testFailureIgnore>
                    <suiteXmlFiles>
                        <suiteXmlFile>src/test/resources/runner/testng.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>

                </plugin>

        </plugins>
    </build>


</project>
heardm
  • 67
  • 1
  • 2
  • 10
  • could you share the `` information of your pom.xml please and what command are you running from command prompt? – Naman Sep 21 '17 at 12:31
  • You may have different maven versions installed. Please make sure your eclipse and terminal maven is the same – Tarun Lalwani Sep 21 '17 at 12:38
  • check out this answer https://stackoverflow.com/questions/46049166/maven-compilation-error-when-run-through-command-line-cucumber-maven-project/46049751#46049751 – Essex Boy Sep 21 '17 at 12:41
  • org.apache.maven.plugins maven-surefire-plugin 2.18.1 false src/test/resources/runner/testng.xml – heardm Sep 21 '17 at 13:00

2 Answers2

2

From the error, it says maven try to download a depedency jar from this remote maven center repository: https://repo.maven.apache.org/maven2/

Because this repository is a SSL website, you need to install its certification to pass the auth. And Maven run by JDK, so you need to import the certication into JDK Security Store.

The reason why you can pass in eclipse is eclipse use a different settings.xml as run maven command, maybe eclipse not use the SSL repository.

There are two options:
1) Don't use SSL maven remote repository, specify a HTTP repository:http://repo1.maven.org/maven2 in your manve settings.xml, like below:

<activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>securecentral</activeProfile>
  </activeProfiles>
  <profiles>
    <profile>
      <id>securecentral</id>
      <!--Override the repository (and pluginRepository) "central" from the
         Maven Super POM -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://repo1.maven.org/maven2</url>
          <releases>
            <enabled>true</enabled>
          </releases>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://repo1.maven.org/maven2</url>
          <releases>
            <enabled>true</enabled>
          </releases>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>

2) Import certification in JDK Security Store
find the step to import in this post: Problems using Maven and SSL behind proxy

yong
  • 13,357
  • 1
  • 16
  • 27
1

I think you are using two different maven,usually eclipse comes with its own maven version. You can verify you are using same Maven installation in eclipse and from command prompt.

You can verify maven installation in eclipse by going to Preference--> Maven--> Installation.

From command prompt, check for Maven home/M2 home.

Maven installation verify in eclipse

Yogi
  • 1,805
  • 13
  • 24
  • so what exactly i should do. mine is selected as emebeded. it is clicked – heardm Sep 21 '17 at 12:59
  • in command prompt it is showing location of downloaded maven path – heardm Sep 21 '17 at 13:02
  • Add external maven using 'Add' button. select maven which you can see in command prompt. And solve the error. If you can share Pom file, it can help identify the problem – Yogi Sep 21 '17 at 13:37
  • how to use embeeded maven in command prompt. if i use external maven from eclipse. it fails – heardm Sep 21 '17 at 13:39
  • It might be in m2e plugins, but i would suggest, it is advisable to use that. Always use maven installed as independent program and solve POM issues – Yogi Sep 21 '17 at 13:42
  • i have writen some part of pom.xml in comment section – heardm Sep 21 '17 at 13:43
  • From error, it seems like proxy issue with Maven, you need to configure JAVA_HOME and proxy in settings.xml file under conf folder of maven. But it would be helpful if you share full POM and full error stack – Yogi Sep 21 '17 at 13:50
  • added pom.xml yogi.please check – heardm Sep 21 '17 at 14:00
  • @heardm-- i just google about error, it seems like some SSL error. You can follow below links for more details: [SunCertPathBuilderException] (https://stackoverflow.com/questions/13626965/how-to-ignore-pkix-path-building-failed-sun-security-provider-certpath-suncertp) – Yogi Sep 21 '17 at 14:52