I'm trying to run a deployment to push a Maven plugin to the Nexus repository, but for some reason, I keep coming up against a rather strange exception: Maven is complaining that org.apache.http.util.Args
is missing. This is especially strange, since the plugin itself does not seem to depend on the org.apache.http
packages directly, and even if it transitively does (more likely), the relevant packages are present in my repository.
I'm not using any special configuration for the plugin, just the bare minimum in the guide. The full stacktrace, as given by Maven:
Caused by: java.lang.NoClassDefFoundError: org/apache/http/util/Args
at org.apache.http.auth.UsernamePasswordCredentials.<init>(UsernamePasswordCredentials.java:78)
at org.sonatype.nexus.client.rest.jersey.NexusClientFactoryImpl.applyAuthenticationIfAny(NexusClientFactoryImpl.java:245)
at org.sonatype.nexus.client.rest.jersey.NexusClientFactoryImpl.doCreateHttpClientFor(NexusClientFactoryImpl.java:136)
at org.sonatype.nexus.client.rest.jersey.NexusClientFactoryImpl.createFor(NexusClientFactoryImpl.java:125)
at org.sonatype.nexus.maven.staging.remote.RemoteNexus.createNexusClient(RemoteNexus.java:189)
at org.sonatype.nexus.maven.staging.remote.RemoteNexus.<init>(RemoteNexus.java:102)
at org.sonatype.nexus.maven.staging.deploy.strategy.AbstractStagingDeployStrategy.createRemoteNexus(AbstractStagingDeployStrategy.java:54)
at org.sonatype.nexus.maven.staging.deploy.strategy.StagingDeployStrategy.deployPerModule(StagingDeployStrategy.java:70)
at org.sonatype.nexus.maven.staging.deploy.DeployMojo.execute(DeployMojo.java:192)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
... 21 more
Caused by: java.lang.ClassNotFoundException: org.apache.http.util.Args
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
... 31 more
Plugin config from my pom.xml:
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
Thank you in advance for any advice!
If anyone else runs into the problem, most likely because the project is otherwise not using Apache HTTP, you can inject the dependency directly into the plugin by editing your POM thus:
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.6</version>
</dependency>
</dependencies>
</plugin>
Note the plugin-specific dependency resolution used to inject HTTP core directly.