Tomcat 10 connection problem in Netbeans 13 - java

I installed Netbeans and Tomcat. This error occurs when I then create and run a sample project. How do I solve this problem? I added Tomcat as a server and it works on localhost. I added the JDK file to the path. I wrote maven plugins in pom file.
--- maven-war-plugin:2.3:war (default-war) # mavenproject1 ---
Error injecting: org.apache.maven.plugin.war.WarMojo
com.google.inject.ProvisionException: Unable to provision, see the following errors:
1) Error injecting constructor, java.lang.ExceptionInInitializerError
at org.apache.maven.plugin.war.WarMojo.<init>(Unknown Source)
while locating org.apache.maven.plugin.war.WarMojo
1 error
at com.google.inject.internal.InternalProvisionException.toProvisionException (InternalProvisionException.java:226)
at com.google.inject.internal.InjectorImpl$1.get (InjectorImpl.java:1053)
...
Caused by: java.lang.ExceptionInInitializerError
at com.thoughtworks.xstream.XStream.setupConverters (XStream.java:679)
...
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module
...
Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.3:war (default-war) on project mavenproject1: Execution default-war of goal org.apache.maven.plugins:maven-war-plugin:2.3:war failed: Unable to load the mojo 'war' in the plugin 'org.apache.maven.plugins:maven-war-plugin:2.3' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: null
-----------------------------------------------------
realm = plugin>org.apache.maven.plugins:maven-war-plugin:2.3
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/C:/Users/selim/.m2/repository/org/apache/maven/plugins/maven-war-plugin/2.3/maven-war-plugin-2.3.jar
...
Number of foreign imports: 1
import: Entry[import from realm ClassRealm[maven.api, parent: null]]
-----------------------------------------------------
: ExceptionInInitializerError: Unable to make field private final java.util.Comparator java.util.TreeMap.comparator accessible: module java.base does not "opens java.util" to unnamed module #f2276c9
-> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

I solve the problem. I'm waiting unpacking central repository

Related

An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar

I have encountered problems while trying to run sonarqube on my application. When I execute the command it throws me an error which doesn't say much to me. Does anyone know where is the problem here?
The Error looks like this:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.257 s
[INFO] Finished at: 2022-12-07T15:10:39+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project TeamTracker: Execution default-cli of goal org.sonarsource.sca
nner.maven:sonar-maven-plugin:3.9.1.2184:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar: java.la
ng.ExceptionInInitializerError: null
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.codehaus.mojo:sonar-maven-plugin:3.9.1.2184
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/A113408609/.m2/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/3.9.1.2184/sonar-maven-plugin-3.9.1.2184.jar
[ERROR] urls[1] = file:/C:/Users/A113408609/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
[ERROR] urls[2] = file:/C:/Users/A113408609/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[3] = file:/C:/Users/A113408609/.m2/repository/org/codehaus/plexus/plexus-utils/3.2.1/plexus-utils-3.2.1.jar
[ERROR] urls[4] = file:/C:/Users/A113408609/.m2/repository/org/sonarsource/scanner/api/sonar-scanner-api/2.16.2.588/sonar-scanner-api-2.16.2.588.jar
[ERROR] urls[5] = file:/C:/Users/A113408609/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] : java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security
.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module #26f204a4
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
'cmd' is not recognized as an internal or external command,
operable program or batch file.
This is a command I execute:
mvn sonar:sonar -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_AUTH_TOKEN -Dsonar.projectKey=$SONAR_PROJECT_KEY -Dsonar.projectName=$CI_PROJECT_PATH_SLUG
I have gone through documentations but I still really can't see what is the problem here :/
When I try to run mvn clean install the build is succesfull.
I am using Java 11, Maven 3.6.3 and Sonar Community Edition Version 8.9.10

org.sonarsource.scanner.maven:sonar-maven-plugin:3.8.0.2131:sonar failed: An API incompatibility was encountered while executing

my Software version
sonarqube 7.0
maven: 3.6.3
jdk: 17
sonar-maven-plugin: 3.8.0.2131
when I run
mvn --batch-mode clean verify
org.sonarsource.scanner.maven:sonar-maven-plugin:3.8.0.2131:sonar
-Dsonar.host.url=http://***
-Dsonar.login=***
-Dsonar.password=***
-Dsonar.issuesReport.console.enable=true
-Dsonar.gitlab.commit_sha=30ddd2484f6a487bcbea96775d497e0bffa87653
-Dsonar.gitlab.ref_name=***
-Dsonar.gitlab.project_id=***
-Dsonar.analysis.mode=preview
-Dsonar.preview.excludePlugins=issueassign,scmstats
-Dmaven.test.skip=true
and I've set this parameter export SONAR_SCANNER_OPTS="--illegal-access=permit"
but it error as follows
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.8.0.2131:sonar (default-cli) on project train-mc: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.8.0.2131:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.8.0.2131:sonar: java.lang.ExceptionInInitializerError: null
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:3.8.0.2131
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/root/.m2/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/3.8.0.2131/sonar-maven-plugin-3.8.0.2131.jar
[ERROR] urls[1] = file:/root/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
[ERROR] urls[2] = file:/root/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[3] = file:/root/.m2/repository/org/codehaus/plexus/plexus-utils/3.2.1/plexus-utils-3.2.1.jar
[ERROR] urls[4] = file:/root/.m2/repository/org/sonarsource/scanner/api/sonar-scanner-api/2.16.0.226/sonar-scanner-api-2.16.0.226.jar
[ERROR] urls[5] = file:/root/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------: java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module #539a50ea
May need to upgrade sonarqube server's version
https://community.sonarsource.com/t/support-java-17-in-the-sonar-maven-plugin/51931

How can I resolve Maven plugin build error?

I am facing the below error while I am importing a plugin to the eclipse, using the existing Maven Project option.
ERROR] Failed to execute goal org.apache.karaf.tooling:karaf-maven-plugin:4.2.7:assembly (install-kar) on project eric-gui-aggregator: Unable to build assembly: Uses constraint violation. Unable to resolve resource org.apache.servicemix.bundles.okhttp [org.apache.servicemix.bundles.okhttp/3.12.1.1] because it is exposed to package 'javax.annotation' from resources system.bundle [system.bundle/0.0.0] and org.jsr-305 [org.jsr-305/3.0.2] via two dependency chains.
[ERROR]
[ERROR] Chain 1:
[ERROR] org.apache.servicemix.bundles.okhttp [org.apache.servicemix.bundles.okhttp/3.12.1.1]
[ERROR] import: (osgi.wiring.package=javax.annotation)
[ERROR] |
[ERROR] export: osgi.wiring.package: javax.annotation
[ERROR] system.bundle [system.bundle/0.0.0]
[ERROR]
[ERROR] Chain 2:
[ERROR] org.apache.servicemix.bundles.okhttp [org.apache.servicemix.bundles.okhttp/3.12.1.1]
[ERROR] import: (osgi.wiring.package=javax.annotation.meta)
[ERROR] |
[ERROR] export: osgi.wiring.package: javax.annotation.meta; uses:=javax.annotation
[ERROR] export: osgi.wiring.package=javax.annotation
[ERROR] org.jsr-305 [org.jsr-305/3.0.2]
I tried to exclude com.google.code.findbugs:jsr305 using the below tag but still I am getting the same build error.
<artifactSet>
<excludes>
<exclude>com.google.code.findbugs:jsr305</exclude>
</excludes>
</artifactSet>
We are using Java 11 in our project.

SQLServerDriver maven dependency causes errors

To fix the org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [com.microsoft.sqlserver.jdbc.SQLServerDriver] error i added this dependency to my pom:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.0.jre7</version>
</dependency>
which is the open code dependency for a SQLServer connection driver, but when i put it, an error my pom.xml appears:
Missing artifact org.codehaus.jackson:jackson-mapper-asl:jar:2.8.1
UPDATED:
If i run the app anyway, the log console shows this trace:
15:42:28,432 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 50) MSC000001: Failed to start service jboss.persistenceunit."vp301b-ear.ear/vp301b.war#unidadPersistencia": org.jboss.msc.service.StartException in service jboss.persistenceunit."vp301b-ear.ear/vp301b.war#unidadPersistencia": java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/ClassLoadingException
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:103)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_80]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_80]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_80]
at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.2.Final-redhat-1.jar:2.1.2.Final-redhat-1]
Caused by: java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/ClassLoadingException
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1404)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1846)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849)
at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:152)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:200)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$600(PersistenceUnitServiceImpl.java:57)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:99)
... 4 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.annotations.common.reflection.ClassLoadingException from [Module "deployment.vp301b-ear.ear.vp301b.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.6.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.6.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.6.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.6.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.6.Final-redhat-1]
... 14 more
When i try to compile it using mvn comile, this is the result:
Failed to execute goal on project vp301b-war: Could not resolve dependencies for project es.xunta.amtega.vp301b:vp301b-war:war:1.0-SNAPSHOT: Failure to find org.codehaus.jackson:jackson-mapper-asl:jar:2.8.1 in http://nexus.xunta.local/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of amtega has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :vp301b-war
As already noted by khmarbaise, the problem is that jackson-mapper-asl-2.8.1.jar is not available in your repository. However I see that mssql-jdbc-6.1.0.jre7.jar has a transitive dependency on version 1.9.2, not 2.8.1, of jackson-mapper-asl so I guess that something you stated is wrong (maybe you were making many attempts). I suggest to try with version 6.4.0.jre7 of the JDBC driver because it doesn't depends on jackson-mapper-asl at all and is the latest jre7-based version available.
Also note that a JDBC driver should not be included in the classpath of your war but in the classpath of the application server (I'm assuming that your web-app accesses the DB in the proper way, that is through a server-provided connection pool, not through DriverManager); this means that the driver should not be a compile-scope dependency in your POM.

Receiving 401 error code while doing a release:perform from my maven build

I've been receiving an error while trying to release a new version of software to Sonatype. I've successfully completed mvn release:prepare but when I do mvn release:perform I get the following error:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:52.660s
[INFO] Finished at: Fri Feb 14 22:32:52 EST 2014
[INFO] Final Memory: 28M/263M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project flexjson: Failed to deploy artifacts: Could not transfer artifact net.sf.flexjson:flexjson:jar:3.2 from/to sonatype-nexus-staging (https://oss.sonatype.org/service/local/staging/deploy/maven2/): Failed to transfer file: https://oss.sonatype.org/service/local/staging/deploy/maven2/net/sf/flexjson/flexjson/3.2/flexjson-3.2.jar. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:00.122s
[INFO] Finished at: Fri Feb 14 22:32:52 EST 2014
[INFO] Final Memory: 14M/184M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.0:perform (default-cli) on project flexjson: Maven execution failed, exit code: '1' -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.0:perform (default-cli) on project flexjson: Maven execution failed, exit code: '1'
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Maven execution failed, exit code: '1'
at org.apache.maven.plugins.release.PerformReleaseMojo.execute(PerformReleaseMojo.java:135)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Caused by: org.apache.maven.shared.release.ReleaseExecutionException: Maven execution failed, exit code: '1'
at org.apache.maven.shared.release.phase.AbstractRunGoalsPhase.execute(AbstractRunGoalsPhase.java:90)
at org.apache.maven.shared.release.phase.RunPerformGoalsPhase.execute(RunPerformGoalsPhase.java:67)
at org.apache.maven.shared.release.DefaultReleaseManager.perform(DefaultReleaseManager.java:343)
at org.apache.maven.shared.release.DefaultReleaseManager.perform(DefaultReleaseManager.java:289)
at org.apache.maven.shared.release.DefaultReleaseManager.perform(DefaultReleaseManager.java:269)
at org.apache.maven.plugins.release.PerformReleaseMojo.execute(PerformReleaseMojo.java:131)
... 21 more
Caused by: org.apache.maven.shared.release.exec.MavenExecutorException: Maven execution failed, exit code: '1'
at org.apache.maven.shared.release.exec.ForkedMavenExecutor.executeGoals(ForkedMavenExecutor.java:122)
at org.apache.maven.shared.release.exec.AbstractMavenExecutor.executeGoals(AbstractMavenExecutor.java:47)
at org.apache.maven.shared.release.exec.ForkedMavenExecutor.executeGoals(ForkedMavenExecutor.java:144)
at org.apache.maven.shared.release.phase.AbstractRunGoalsPhase.execute(AbstractRunGoalsPhase.java:82)
... 26 more
I found blog post about the error, but I don't see anything that matches my setup.
http://blog.sonatype.com/2010/11/what-to-do-when-nexus-returns-401/#.Uv7EYEKwJUI
The post refers to the settings file not matching what's configured in the pom. But I don't have anything in the pom about deployment. I don't have a plugin configured so it must've been using the default plugin configuration for doing releases. As I understand it that's the maven release plugin.
This setup has worked in the past, but I'm doing this from another machine. I had to generate a new gpg private key following this post:
http://blog.sonatype.com/2010/01/how-to-generate-pgp-signatures-with-maven/#.Uv2JUkKwJUI
This setup has worked before, but I've moved to the new machine. I made sure to copy the .m2/settings.xml file to my ~/.m2/settings.xml. Of course that private key is different than the one I had on my old machine. But I can't figure out why that matters or if that matters. From what I've read it's just for code signing. Not sure how that authorizes code signings.
So what am I missing? Why does this 401 error keep happening?
Follow the advice in the first link. 401 means a failure to authenticate against the server. You state that you have nothing configured in your POM to support deployment. If this has previously worked, that cannot be correct. Is there a distribution management section in your POM?
<distributionManagement>
<repository>
<id>nexus-release</id>
<name>My Nexus release area</name>
<url>https://????????</url>
</repository>
</distributionManagement>
The id section must match the id of the "servers" section in your Maven settings file.
<server>
<id>nexus-release</id>
<username>mark</username>
<password>mycleartextpasswordconsiderusingmavenbuiltinencryption</password>
</server>
This is the "gotcha" and illustrates how Maven links the target repo with the user authentication credentials.
Finally to make your my build uses the correct settings file I always pass it as a parameter to by build:
mvn -s ~/.m2/settings.xml ....
This approach also enables different settings files for different projects.
Note
The second link is unrelated. It deals with signing the artifact you
are publishing (so that others will trust it came from you).
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project flexjson: Failed to deploy artifacts: Could not transfer artifact net.sf.flexjson:flexjson:jar:3.2 from/to sonatype-nexus-staging (https://oss.sonatype.org/service/local/staging/deploy/maven2/): Failed to transfer file: https://oss.sonatype.org/service/local/staging/deploy/maven2/net/sf/flexjson/flexjson/3.2/flexjson-3.2.jar. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]
regenerate your maven master password and encrypt your password for your nexus repository and configure it in your ~/.m2 settings.xml
Similar to OP, I do not have a distributionManagement section in my pom.xml so I got this error without knowing what to put in the Maven settings file.
The error message above shows the default repository name sonatype-nexus-staging used in the maven release plugin. This is what needs to match the login/password (encrypted or not) in settings.xml.
Keep all your settings file in both %M2_HOME/conf as well as in ~/.m2/ folder.
Then you will not get this error message.

Categories