kloudtek / anypoint-tools

REPOSITORY HAS MOVED - SEE README below
https://gitlab.com/aeontronix/oss/anypoint-tools/
4 stars 0 forks source link

maven plugin not using maven proxy settings #8

Open mikeliu89 opened 5 years ago

mikeliu89 commented 5 years ago

Here is the error:

.................... [DEBUG] File is mule-application [DEBUG] Searching for org LID [DEBUG] HTTP GET /accounts/api/me [DEBUG] HTTP POST /accounts/login data={password==, username=} [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 08:25 min [INFO] Finished at: 2018-11-07T08:47:37-08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal com.kloudtek.anypoint-tools:anypoint-maven-plugin:0.9.37:hdeploy (deploy-arm) on project hello-world-ping-api: null: MojoExecutionException: RuntimeIOException -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.kloudtek.anypoint-tools:anypoint-maven-plugin:0.9.37:hdeploy (deploy-arm) on project hello-world-ping-api: null at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213) 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:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288) at org.apache.maven.cli.MavenCli.main (MavenCli.java:192) 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.apache.maven.plugin.MojoExecutionException at com.kloudtek.anypoint.AbstractDeployMojo.execute (AbstractDeployMojo.java:125) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) 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:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288) at org.apache.maven.cli.MavenCli.main (MavenCli.java:192) 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: com.kloudtek.anypoint.util.HttpHelper$RuntimeIOException at com.kloudtek.anypoint.util.HttpHelper.doExecute (HttpHelper.java:229) at com.kloudtek.anypoint.util.HttpHelper.executeWrapper (HttpHelper.java:183) at com.kloudtek.anypoint.util.HttpHelper.executeWrapper (HttpHelper.java:171) at com.kloudtek.anypoint.util.HttpHelper.execute (HttpHelper.java:157) at com.kloudtek.anypoint.util.HttpHelper.httpPost (HttpHelper.java:101) at com.kloudtek.anypoint.AnypointClient.authenticate (AnypointClient.java:187) at com.kloudtek.anypoint.util.HttpHelper.executeWrapper (HttpHelper.java:177) at com.kloudtek.anypoint.util.HttpHelper.executeWrapper (HttpHelper.java:171) at com.kloudtek.anypoint.util.HttpHelper.httpGet (HttpHelper.java:68) at com.kloudtek.anypoint.AnypointClient.findOrganizations (AnypointClient.java:110) at com.kloudtek.anypoint.AnypointClient.findOrganization (AnypointClient.java:120) at com.kloudtek.anypoint.AbstractDeployMojo.execute (AbstractDeployMojo.java:111) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) 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:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288) at org.apache.maven.cli.MavenCli.main (MavenCli.java:192) 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) [ERROR] [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

ymenager commented 5 years ago

can you include your POM (make sure to remove sensitive details like password, org ids, etc)

ymenager commented 5 years ago

Well in any case it probably needs some better error handling in that spot... I'll add that

ymenager commented 5 years ago

ok, that error means the username or the password weren't set... set properties "anypoint.username" and "anypoint.password", or include them in the config as in the example:

<plugin>
    <groupId>com.kloudtek.anypoint-tools</groupId>
    <version>1.0-SNAPSHOT</version>
    <artifactId>anypoint-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>hdeploy</id>
            <phase>deploy</phase>
            <goals>
                <goal>hdeploy</goal>
            </goals>
            <configuration>
                <username>[anypointusername]</username>
                <password>[anypointpassword]</password>
                <org>[orgname]</org>
                <env>[envname]</env>
                <target>[target name, can be either cluster name, server group name or server name]</target>
            </configuration>
        </execution>
    </executions>
</plugin>
ymenager commented 5 years ago

I've added extra validation to give better errors if username/password missing

mikeliu89 commented 5 years ago

hi, username and password is there, I just blank them out when I posted it here

mikeliu89 commented 5 years ago

I tried to use postman calling both https://anypoint.mulesoft.com/hybrid/api/v1/accounts/login and https://anypoint.mulesoft.com/accounts/login with headers below: X-ANYPNT-ORG-ID: X-ANYPNT-ENV-ID: Content-Type:application/json Accept:application/json Authorization:

and the POST body of: {"username":"[]","password":"[]"}

And I got HTTP 401 code (unauthorized)

mikeliu89 commented 5 years ago

I removed the org id and env id as well as usename and password in the above comment

mikeliu89 commented 5 years ago

And I removed the Bearer token in the above comment for security reason, but these data all there when I sent the post requests, but got 401 code

mikeliu89 commented 5 years ago

could it be the proxy issue since out Mule server is in DMZ and I'm run the deployment and postman inside of corp net. But this is actually calling the API in the Anypoint cloud, right?

ymenager commented 5 years ago

@mikeliu89 In your stacktrace it seems you're using the maven plugin right ? So I'm going to need to see the pom.xml you're using to ascertain what the issue is.

From what the logs say it does seem to be a missing username/password value thou

mikeliu89 commented 5 years ago

I provided the usename and password in the mvn deploy command line

mikeliu89 commented 5 years ago

If you can do GoToMeeting or WebEx, I can show you all the details

mikeliu89 commented 5 years ago

By the way, we are doing on-prem Mule API deployment

mikeliu89 commented 5 years ago

I just run the command on a guest network (bypass proxy) and got the same 401 (unauthorized) when calling the /accounts/login api

ymenager commented 5 years ago

ok i think this is caused by having to use a proxy, and I'm not reusing the proxy settings from settings.xml, so that's a bug need to fix.