Reputation: 159
Trying to deploy to our AWS VM Instances (havng mule runtimes 3.8.5). Our Jenkins Job has triggered the deployment and getting 401 Unauthorized. Verified the creds are working fine and no special characters. Not sure what else could be wrong. Can someone suggest me from below logs.
One other doubt is the does the aws region causes an issue ? ( the instances running on west but on jenkins build job its showing east)
Failed: 401 Unauthorized: Unauthorized
[ERROR] Failed to deploy XXXX: Failed to deploy application XXXX
org.mule.tools.maven.plugin.mule.DeploymentException: Failed to deploy application XXX
at org.mule.tools.maven.plugin.mule.arm.ArmDeployer.deploy(ArmDeployer.java:55)
at org.mule.tools.maven.plugin.mule.DeployMojo.deployWithDeployer(DeployMojo.java:194)
at org.mule.tools.maven.plugin.mule.DeployMojo.arm(DeployMojo.java:177)
at org.mule.tools.maven.plugin.mule.DeployMojo.doExecute(DeployMojo.java:154)
at org.mule.tools.maven.plugin.mule.AbstractMuleMojo.execute(AbstractMuleMojo.java:214)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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.mule.tools.maven.plugin.mule.ApiException: 401 Unauthorized: Unauthorized
at org.mule.tools.maven.plugin.mule.AbstractMuleApi.validateStatusSuccess(AbstractMuleApi.java:78)
at org.mule.tools.maven.plugin.mule.AbstractMuleApi.getBearerToken(AbstractMuleApi.java:69)
at org.mule.tools.maven.plugin.mule.AbstractMuleApi.init(AbstractMuleApi.java:60)
at org.mule.tools.maven.plugin.mule.arm.ArmDeployer.deploy(ArmDeployer.java:38)
Upvotes: 0
Views: 4189
Reputation: 16505
401 means : The HTTP 401 Unauthorized client error status response code indicates that the request has not been applied because it lacks valid authentication credentials for the target resource.
So, possible causes are:
Jenkins or mule-maven-plugin bug are not common. Human error is very common.
In order to validate who is causing the error?, I advice you validate your credentials directly to Anypoint http url
Reviewing the plugin official source code v2.2.1 related to your stacktrace ArmDeployer.deploy(ArmDeployer.java:38)
:
https://github.com/mulesoft/mule-maven-plugin/tree/v2.2.1
And its classes (in this order):
I got the base url:
ArmApi(null, "https://anypoint.mulesoft.com", USERNAME, PASSWORD, ENVIRONMENT, "", false);
And with this url, I found this authentication request snippet:
curl -H "Content-Type: application/json" -X POST -d '{"username":"jane","password":"doe"}' https://anypoint.mulesoft.com/accounts/login
Also in this web , another ways to authentication are showed:
If https://anypoint.mulesoft.com/accounts/login
returns you a successful answer, will indicate that there are some error at credentials manager in your jenkins or just an error in the human jenkins admin.
If https://anypoint.mulesoft.com/accounts/login
returns you an error answer like your 401 Unauthorized, will indicate that mule-maven-plugin:2.2.1 and jenkins are good, and your credentials are wrong!!! or maybe they expired.
Anyway just to try, reset the credentials or ask for a new user/password.
Upvotes: 1