error: Task :publishMavenPublicationToNexusRepository FAILED - repository

Here is the error i am getting while deploying artifacts to nexus repository :
Failed to retrieve remote metadata com.example:java-maven-app:1.1.0-SNAPSHOT/maven-metadata.xml: Could not transfer metadata
com.example:java-maven-app:1.1.0-SNAPSHOT/maven-metadata.xml from/to nexus-snapshots (http://64.227.148.173:8081/repository/maven
-snapshots/): authentication failed for http://64.227.148.173:8081/repository/maven-snapshots/com/example/java-maven-app/1.1.0-SN
APSHOT/maven-metadata.xml, status: 401 Unauthorized enter image description hereenter code here
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>java-maven-app</artifactId>
<version>1.1.0-SNAPSHOT</version>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.5.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- to handle any Java version mismatch, add the following configuration for maven-compiler-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<distributionManagement>
<snapshotRepository>
<id>nexus-snapshots</id>
<url>http://64.227.148.173:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.3.4.RELEASE</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>6.4</version>
</dependency>
</dependencies>
</project>
I had added all the required code in pom.xml file and made all changes but getting this error please help me with solving this issue.

That's a 401 error. Login credentials were not sent, or invalid login credentials were sent. You need to ensure the settings.xml file has a "server" section that matches the ID shown in that message after "from/to", which in your case is "nexus-snapshots". That should hold the login credentials needed to access Nexus Repo.
<settings>
<servers>
<server>
<id>nexus-snapshots</id>
<username>userid</username>
<password>password</password>
</server>
</servers>
...
</settings>

Related

When running via maven, my tests are not found in the junit project

screenshot 1
As in the screenshot 1 I'm trying to run my set of autotests, the build works successfully, but not a single test is defined.
screenshot 2
Screenshot 2 shows the result after running through maven
If you run tests separately, through "run test", but everything starts and runs according to the script
my POM file:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>src/test/java/</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
</plugins>
</build>`
I want that tests were defined in all classes.
I tried to play with the pom file, apparently there are problems in it, but nothing happens.
link to project
i fix problem
my pom:
<?xml version="1.0" encoding="UTF-8"?>
4.0.0
<groupId>org.example</groupId>
<artifactId>Test_Framework</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<selenium.version>4.6.0</selenium.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>

Why URL not working with Selenium in FirefoxDriver?

I have a Selenium, TestNG and maven application.
If I run mvn intergration-test the Firefox browser opens but URL not working.
Also getting the below error in the console
Failed to connect to binary FirefoxBinary(C:\Program Files (x86)\Mozilla Firefox\firefox.exe) on port 7055
my pom.xml
<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>Selenium</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Selenium</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.selenium>2.53.1</version.selenium>
<version.testng>6.9.10</version.testng>
<version.maven.compiler.plugin>2.3.2</version.maven.compiler.plugin>
<version.java.source>1.8</version.java.source>
<version.java.target>1.8</version.java.target>
</properties>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${version.testng}</version>
<scope>test</scope>
</dependency>
<dependency>
<!-- <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-server-standalone</artifactId>
<version>${version.selenium}</version> <scope>test</scope> -->
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${version.maven.compiler.plugin}</version>
<configuration>
<source>${version.java.source}</source>
<target>${version.java.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Xms128m -Xmx256m -XX:PermSize=128m -XX:MaxPermSize=256m</argLine>
<parallel>true</parallel>
<suiteXmlFiles>
<suiteXmlFile>src/main/java/com/selenium/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<!-- Skip the normal tests, we'll run them in the integration-test phase -->
<skip>true</skip>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
I usually see such behavior when the browser version is not compatible with your driver version, from you pom i see you are using selenium ver 2.25, this is a bit old and i think only supports FF 14. Please verify that you are using the correct version of firefox. if you need help installing an older version of firefox see this:
https://support.mozilla.org/en-US/kb/install-older-version-of-firefox

Maven Dependency - Failure to find eviware:maven-soapui-plugin:jar:4.5.1

I am running Soapui test using Intelliji, however I am unable to run test via Maven. Normal test works fine using SoapUITestRunner.
I am getting below error, even though I have eviware:maven-soapui-plugin:jar:4.5.1 in my project path and under .m2 repository.
Error:
Failed to execute goal on project webservice: Could not resolve dependencies for project webservice:webservice:jar:1.0-SNAPSHOT: Failure to find eviware:maven-soapui-plugin:jar:4.5.1 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
Appreciate your help.
Best Regards,
Kam
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>webservice</groupId>
<artifactId>webservice</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.soapui.plugin.version>4.5.1</maven.soapui.plugin.version>
<soapui.repo.url>http://www.soapui.org/repository/maven2/</soapui.repo.url>
</properties>
<pluginRepositories>
<pluginRepository>
<id>eviwarePluginRepository</id>
<url>http://www.soapui.org/repository/maven2/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>eviware</groupId>
<artifactId>maven-soapui-plugin</artifactId>
<version>4.5.1</version>
</dependency>
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<!-- Source directory configuration -->
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
<testFailureIgnore>true</testFailureIgnore>
<!-- Setting properties for test execution -->
<properties>
<!-- Setting ReportNG listeners -->
<property>
<name>listener</name>
<value>org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter</value>
</property>
</properties>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>eviware</groupId>
<artifactId>maven-soapui-plugin</artifactId>
<version>4.5.1</version>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
<configuration>
<projectFile>${project.basedir}/SoapUIAutomationDemo.xml</projectFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Remove your cached jars from C:\Users\.m2\repository\com\smartbear.
enable proxy if any in your settings.xml under .m2 folder.

Change maven dependency for artifact using classifier

With the maven jar plugin I build two jar: bar-1.0.0.jar and bar-1.0.0-client.jar.
Actually in my POM I have the following dependency:
<dependency>
<groupId>de.app.test</groupId>
<artifactId>foo</artifactId>
<version>1.0.0</version>
</dependency>
This artifact exist also in two version bar-1.0.0.jar and bar-1.0.0-client.jar
I want to make bar-1.0.0-client.jar dependent of foo-1.0.0-client.jar and bar-1.0.0.jar dependent of foo-1.0.0.jar.
================
->First (wrong) solution: define the scope as provided and use the right foo package when using bar.jar
->Second (long) solution : Add 'server' classifier to the other jar. Use different profile to build the foo artifact and put the classifier in a property.
<dependency>
<groupId>de.app.test</groupId>
<artifactId>foo</artifactId>
<version>1.0.0</version>
<classifier>${profile.classifier}<classifier>
</dependency>
================
Concerning the profile solution.
Interfaces module pom
<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">
<parent>
<groupId>com.app</groupId>
<artifactId>myapp-parent</artifactId>
<version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.app</groupId>
<artifactId>myapp-interfaces</artifactId>
<version>1.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>myapp Interfaces</name>
<profiles>
<profile>
<id>server</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>jar-server</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>server</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>client</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>jar-client</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>client</classifier>
<excludes>
<exclude>**/server/**</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Implementation module pom
<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">
<parent>
<groupId>com.app</groupId>
<artifactId>myapp-parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.app</groupId>
<artifactId>myapp-model</artifactId>
<version>1.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>myapp Model</name>
<properties>
<myapp-interfaces.classifier></myapp-interfaces.classifier>
<myapp-interfaces.version>1.1.0-SNAPSHOT</myapp-interfaces.version>
</properties>
<dependencies>
<dependency>
<groupId>com.app</groupId>
<artifactId>myapp-interfaces</artifactId>
<version>${myapp-interfaces.version}</version>
<classifier>${myapp-interfaces.classifier}</classifier>
</dependency>
[...]
</dependencies>
<profiles>
<profile>
<id>server</id>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>jar-server</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>server</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.app</groupId>
<artifactId>myapp-interfaces</artifactId>
<version>${myapp-interfaces.version}</version>
<classifier>${myapp-interfaces.classifier}</classifier>
</dependency>
</dependencies>
<properties>
<myapp-interfaces.classifier>server</myapp-interfaces.classifier>
</properties>
</profile>
<profile>
<id>client</id>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>jar-client</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>client</classifier>
<excludes>
<exclude>**/server/**</exclude>
<exclude>**/META-INF/services/**</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<myapp-interfaces.classifier>client</myapp-interfaces.classifier>
</properties>
<dependencies>
<dependency>
<groupId>com.app</groupId>
<artifactId>myapp-interfaces</artifactId>
<version>${myapp-interfaces.version}</version>
<classifier>${myapp-interfaces.classifier}</classifier>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
The problem with this solution is due to the fact that my client interface have some missing interfaces and maven throw a compilation error during the compile phase.
And if I use myapp-model and an other project I didn't not have dependency to the right myapp-interface.
I wonder if it's possible to build a jar and put a specific pom inside ?
For the Interfaces.
I change nothing and build the both interfaces.jar (client + server).
For the Model
I import the both jar as optional
<dependency>
<groupId>com.app</groupId>
<artifactId>myapp-interfaces</artifactId>
<version>${myapp-interfaces.version}</version>
<classifier>client</classifier>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.app</groupId>
<artifactId>myapp-interfaces</artifactId>
<version>${myapp-interfaces.version}</version>
<classifier>server</classifier>
<optional>true</optional>
</dependency>
With that I can build the both model's version without any error.
In my client application and server application
For each application I create the dependency to the right interfaces.jar and models.jar

How to include automatically xmlbeans generated code into maven jar?

I have a project which uses Apache Xmlbeans for databinding. Currently it is very simple it only has some Schema-Files in src/main/xsd and xsdconfig in src/main/xsdconfig.
I want to include the generated Classes into the generated jar-File. It works if I specify the xmlbeans goal:
"mvn xmlbeans:xmlbeans package" --> Creates a Jar with the xmlbeans classes
But I want to do this within the normal build cycle: "mvn package" --> should create a jar with the xmlbeans classes, but won't.
The pom is the following:
<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>org.test</groupId>
<artifactId>xmlbeans-maven-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>maven-xmlbeans-plugin</artifactId>
<version>2.3.3</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.4.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
I tried to bind it manually to the "generate-sources" (And to the "compile" phase, too) phase, but it does not work.
<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>de.leradon</groupId>
<artifactId>xmlbeans-maven</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>maven-xmlbeans-plugin</artifactId>
<version>2.3.3</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>xmlbeans</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.4.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
How can I configure the plugin, so that when I run "mvn package" all the generated classes are packaged into the jar?
Greetings,
lerad
If you configure the plugin under pluginManagement, you still need to declare it under plugins. To simplify, I'm not using the pluginManagement in the pom.xml below:
<project>
...
<dependencies>
...
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.4.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xmlbeans-maven-plugin</artifactId>
<version>2.3.3</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>xmlbeans</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
With this POM (and some XSD in src/main/xsd which is the default location), running mvn clean package just works (i.e. sources are generated from the XSD, compiled and packaged as part of the build).
Try this.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xmlbeans-maven-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id />
<phase>generate-sources</phase>
<goals>
<goal>xmlbeans</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>src/main/xsd</schemaDirectory>
<staleFile>${project.build.directory}/generated-sources/xmlbeans/.staleFlag</staleFile>
<verbose>false</verbose>
<quiet>false</quiet>
<javaSource>1.6</javaSource>
</configuration>
</plugin>