We are trying to use apigee-config-maven-plugin to deploy targetservers, kvms, apiproducts. In the parent pom xml, instead of providing username & password from command line, we tried using credentials from Maven settings.xml as below. we are getting nullpointer exception. The same profile setup works fine for apigee-edge-maven-plugin though.
We used sample shared-pom-config xml provided in GItHub and just replaced environment details & provided credentials information from settings.xml reference. we ran install command and got NullPointer exception. If we provide username & password from command line ( similar to the sample xml file in GITHub), then it works fine.
Could you please let us know if apigee-config-maven-plugin supports reading credentials from maven settings file.
profile setup in parent/shared-pom-config xml file configuration:
<profiles> <profile> <id>dev</id> <properties> <org>org</org> <apigee.profile>dev</apigee.profile> <apigee.hosturl>https://hostname:port</apigee.hosturl> <apigee.apiversion>v1</apigee.apiversion> <apigee.org>${org}</apigee.org> <apigee.env>dev</apigee.env> <apigee.username>${settings.servers.apigeecred.username}</apigee.username> <apigee.password>${settings.servers.apigeecred.password}</apigee.password> </properties> </profile> </profiles>
Maven settings.xml entry:
<server> <id>apigeecred</id> <username>foo</username> <password>{COQLCE6DU6GtcS5P=}</password> </server>
Exception when running the job:
[ERROR] Failed to execute goal com.apigee.edge.config:apigee-config-maven-plugin:1.2.1:caches (create-config-cache) on project SurveyAPIConfig: Execution create-config-cache of goal com.apigee.edge.config:apigee-config-maven-plugin:1.2.1:caches failed. NullPointerException -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.apigee.edge.config:apigee-config-maven-plugin:1.2.1:caches (create-config-cache) on project SurveyAPIConfig: Execution create-config-cache of goal com.apigee.edge.config:apigee-config-maven-plugin:1.2.1:caches failed. at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224) 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:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155) at org.jvnet.hudson.maven3.launcher.Maven31Launcher.main(Maven31Launcher.java:132) 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:497) at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:330) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:238) at jenkins.maven3.agent.Maven31Main.launch(Maven31Main.java:181) 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:497) at hudson.maven.Maven3Builder.call(Maven3Builder.java:136) at hudson.maven.Maven3Builder.call(Maven3Builder.java:71) at hudson.remoting.UserRequest.perform(UserRequest.java:120) at hudson.remoting.UserRequest.perform(UserRequest.java:48) at hudson.remoting.Request$2.run(Request.java:326) at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: org.apache.maven.plugin.PluginExecutionException: Execution create-config-cache of goal com.apigee.edge.config:apigee-config-maven-plugin:1.2.1:caches failed. at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:143) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 30 more Caused by: java.lang.NullPointerException at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:187) at com.google.api.client.http.HttpHeaders.setBasicAuthentication(HttpHeaders.java:616) at com.apigee.edge.config.rest.RestUtil.executeAPI(RestUtil.java:922) at com.apigee.edge.config.rest.RestUtil.getEnvConfig(RestUtil.java:299) at com.apigee.edge.config.mavenplugin.CacheMojo.getCache(CacheMojo.java:296) at com.apigee.edge.config.mavenplugin.CacheMojo.doUpdate(CacheMojo.java:130) at com.apigee.edge.config.mavenplugin.CacheMojo.execute(CacheMojo.java:219) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132) ... 31 more [ERROR]
HI @soujanyaedunuri - not sure why they dont work here ? Are you sure you have the setup for deploy plugin as well ? Can you share profile details to me ? Using the settings.xml is a Maven thing and nothing to do with the plugin.
If you dont want to pass it via command line, you can always create profile in the settings.xml
<profiles> <profile> <id>test</id> <properties> <org>saisarantest</org> <username>example@example.com</username> <password>iamasecret</password> <env>test</env> </properties> </profile> </profiles> <activeProfiles> <activeProfile>test</activeProfile> </activeProfiles>
And in your mvn command, you can just pass -P{name}, it will pick both the properties from settings and from your pom
I found the solution for this problem. in the parent pom xml, if we are trying to read encrypted passwords from settings.xml, then we should add below extension under <build> parameter.
<build> <extensions> <extension> <!-- This extension is required for encrypted password --> <groupId>com.github.shyiko.servers-maven-extension</groupId> <artifactId>servers-maven-extension</artifactId> <version>1.3.1</version> </extension> </extensions> <plugins> <plugin> <groupId>com.apigee.edge.config</groupId> <artifactId>apigee-config-maven-plugin</artifactId> <version>1.2.1</version> <executions> <!-- <execution> <id>create-config-cache</id> <phase>install</phase> <goals> <goal>caches</goal> </goals> </execution> --> <execution> <id>create-config-targetserver</id> <phase>install</phase> <goals> <goal>targetservers</goal> </goals> </execution> <execution> <id>create-config-kvm</id> <phase>install</phase> <goals> <goal>keyvaluemaps</goal> </goals> </execution> <execution> <id>create-config-resourcefiles</id> <phase>install</phase> <goals> <goal>resourcefiles</goal> </goals> </execution> <execution> <id>create-config-apiproduct</id> <phase>install</phase> <goals> <goal>apiproducts</goal> </goals> </execution> <execution> <id>create-config-developer</id> <phase>install</phase> <goals> <goal>developers</goal> </goals> </execution> <execution> <id>create-config-app</id> <phase>install</phase> <goals> <goal>apps</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
Thanks for sharing this. This is useful. Will try it out too. But I still dont understand how it worked for deploy ? Did you include that extension in that pom as well ?
Hi Saran,
Yes, I included this extension for apigee-edge-maven-plugin ( for proxy deployment)I compared both files and found this difference. We are using encrypted passwords in the settings.xml.
Awesome. Thanks
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |