Maven build creates target but fails to complete build

Hi @Sai Saran Vaidyanathan,

I'm using Maven build & Jenkins to try automated deployment.

I'm not sure what is wrong with my pom.xml that is causing build failure.

Can someone please help me with rectifying the error.

[ERROR] Failed to execute goal io.apigee.build-tools.enterprise4g:apigee-edge-maven-plugin:1.1.7:deploy (deploy-bundle-step) on project GeoLocation: MojoExecutionException: NullPointerException 
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>apigee</groupId>
<artifactId>GeoLocation</artifactId>
<version>1.0</version>
<name>GeoLocation</name>
<packaging>pom</packaging>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>https://repo1.maven.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
</pluginRepositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<org.slf4j.simpleLogger.defaultLogLevel>info</org.slf4j.simpleLogger.defaultLogLevel>
<project.root.dir>${basedir}</project.root.dir>
<target.root.dir>${basedir}/target</target.root.dir>
<deployment.suffix>${user.name}</deployment.suffix>
<commit></commit>
<branch>a local</branch>
</properties>
<!-- This is where you add the environment specific properties under various profile names -->
<!-- For apigee.options, refer to "Advanced Configuration Options" under https://github.com/apigee/apigee-deploy-maven-plugin#pom-xml-sample -->
<profiles>
<profile>
<id>test</id>
<properties>
<apigee.profile>test</apigee.profile>
<apigee.env>test</apigee.env>
<apigee.hosturl>https://api.enterprise.apigee.com</apigee.hosturl>
<apigee.apiversion>v1</apigee.apiversion>
<apigee.org>XXXXXXXXXX</apigee.org>
<apigee.username>XXXXXXXXXX</apigee.username>
<apigee.password>XXXXXXXXXX</apigee.password>
<apigee.options>update</apigee.options>
<api.northbound.domain>XXXXXXXXXX</api.northbound.domain>
<api.testtag>~@wip</api.testtag>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<apigee.profile>prod</apigee.profile>
<apigee.env>prod</apigee.env>
<apigee.hosturl>https://api.enterprise.apigee.com</apigee.hosturl>
<apigee.apiversion>v1</apigee.apiversion>
<apigee.org>XXXXXXXXXX</apigee.org>
<apigee.username>XXXXXXXXXX</apigee.username>
<apigee.password>XXXXXXXXXX</apigee.password>
<apigee.options>override</apigee.options>
<apigee.override.delay>5</apigee.override.delay>
<api.northbound.domain>XXXXXXXXXX</api.northbound.domain>
<api.testtag>~@wip,~@mock</api.testtag>
</properties>
</profile>
</profiles>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>io.apigee.build-tools.enterprise4g</groupId>
<artifactId>apigee-edge-maven-plugin</artifactId>
<version>1.1.7</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<!-- copy the full apiproxy folder to target folder -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<resources>
<resource>
<!--source -->
<directory>${project.root.dir}</directory>
<filtering>true</filtering>
<includes>
<include>apiproxy/**</include>
<include>test/integration/**</include>
</includes>
</resource>
</resources>
<!--target -->
<outputDirectory>${target.root.dir}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.apigee.build-tools.enterprise4g</groupId>
<artifactId>apigee-edge-maven-plugin</artifactId>
<executions>
<execution>
<id>configure-bundle-step</id>
<phase>package</phase>
<goals>
<goal>configure</goal>
</goals>
</execution>
<!--deploy bundle -->
<execution>
<id>deploy-bundle-step</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- cleaning dirs -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>auto-clean-init</id>
<phase>initialize</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
<execution>
<id>auto-clean-install</id>
<phase>install</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> 
0 9 603
9 REPLIES 9

@Matthew - Can you please share the mvn command you are calling with args please. You can redact the actual values. I just want to see the command and the args

I'm not using command line for build, I'm doing the build through Jenkins UI.

Ok - What is the mvn command that Jenkins is making ? Can you share that file ?

Ok I figured out couple of things here,

I dint configure Goals & Options in Jenkins, thought values provided in pom.xml are sufficient

after I updated goals & options in jenkins, I re ran the build & I saw

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (auto-clean-init) on project GeoLocation: Failed to clean project: Failed to delete E:\XXXXXXXXXXXXX 

So I deleted this portion from pom.xml

<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>auto-clean-init</id>
<phase>initialize</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
<execution>
<id>auto-clean-install</id>
<phase>install</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin> 
mvn -f GeoLocation/pom.xml install -Pprod -Dusername=XXXXXXXXXXX -Dpassword=XXXXXXXXXX -Dapigee.config.options=update 
[ERROR] {
[ERROR]   "code" : "messaging.config.beans.InvalidServerReferenceInTarget",
[ERROR]   "message" : "Target default has invalid server reference maps. Context Revision:1;APIProxy:GeoLocation;Organization:XXXXXXXXXX;Environment:prod",
[ERROR]   "contexts" : [ ],
[ERROR]   "cause" : {
[ERROR]     "code" : "messaging.config.beans.TargetServerDoesNotExist",
[ERROR]     "message" : "Target server maps does not exist in environment prod",
[ERROR]     "contexts" : [ ]
[ERROR]   }
[ERROR] }

Looks like its trying to deploying but failed as the target server is not configured in the prod environment. Please configure the target server used by proxy.. or else include that in the pom by using the Maven config plugin

Sure, I'm trying to understand why this plugin failed.

<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>auto-clean-init</id>
<phase>initialize</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
<execution>
<id>auto-clean-install</id>
<phase>install</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>

Probably it failed because the target folder was not there. You can remove that plugin from your pom and just use the default "clean" that Maven supports.

10244-maven-plugin.jpg

I can see the target folder

In my sample, I can see that the plugin is deleting the target folder.