We have been using the adapter-builder task (com.worklight.ant.builders.AdapterBuilderTask) to compile our MFP adapters for several weeks. We just started now adopting Java adapters in our MFP apps but we cannot compile them with the adapter-builder task.
Looking at the compilation errors in the output, it seems the adapter-builder task does not have the correct class path for compilation; it is probably missing the worklight-jee-library.jar.
Is this a known issue? Is there a fix available for this? Here’s the output we get when compiling with the adapter-builder task:
$ gradle -b build-mfp.gradle deployMFPNativeProject -PmfpProjectFolder=/Users/olivieri/git/Ready.App.5.Loyalty/LoyaltyReadyApp -PoutputFolder=/Users/olivieri/tmp -PmfpServerURL=http://localhost:8080 -PiOSProjectFolder=/Users/olivieri/git/Ready.App.5.Loyalty/LoyaltyReadyAppiOS -PmfpHybridFlag=false
MFP CLI path: /Applications/IBM/MobileFirst-CLI
Path to ant builder JAR: /Applications/IBM/MobileFirst-CLI/public/worklight-ant-builder.jar
MFP project folder: /Users/olivieri/git/Ready.App.5.Loyalty/LoyaltyReadyApp
outputFolder: /Users/olivieri/tmp
MFP server: http://localhost:8080
MFP project name: LoyaltyReadyApp
MFP apps folder: /Users/olivieri/git/Ready.App.5.Loyalty/LoyaltyReadyApp/apps
:deriveProperties UP-TO-DATE
:loadAntTasks UP-TO-DATE
:buildMFPArtifacts
[ant:war-builder] Ignoring contents of 'server/java' folder. To include this folder, set the 'compileJava' property to true.
mfpHybridFlag: false
About to build native app named: Loyalty
Adapters found.
About to build adapter named: LoyaltyUserAdapter
[ant:echo] Worklight Ant task version 7.0.0.00.20150608-1356
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterApplication.java:11: error: package com.worklight.wink.extensions does not exist
[ant:adapterBuilder] import com.worklight.wink.extensions.MFPJAXRSApplication;
[ant:adapterBuilder] ^
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterApplication.java:13: error: cannot find symbol
[ant:adapterBuilder] public class LoyaltyUserAdapterApplication extends MFPJAXRSApplication{
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: class MFPJAXRSApplication
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:13: error: package javax.ws.rs does not exist
[ant:adapterBuilder] import javax.ws.rs.GET;
[ant:adapterBuilder] ^
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:14: error: package javax.ws.rs does not exist
[ant:adapterBuilder] import javax.ws.rs.Path;
[ant:adapterBuilder] ^
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:15: error: package javax.ws.rs does not exist
[ant:adapterBuilder] import javax.ws.rs.PathParam;
[ant:adapterBuilder] ^
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:16: error: package javax.ws.rs does not exist
[ant:adapterBuilder] import javax.ws.rs.Produces;
[ant:adapterBuilder] ^
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:17: error: package javax.ws.rs.core does not exist
[ant:adapterBuilder] import javax.ws.rs.core.MediaType;
[ant:adapterBuilder] ^
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:19: error: package org.apache.commons.codec.binary does not exist
[ant:adapterBuilder] import org.apache.commons.codec.binary.Base64;
[ant:adapterBuilder] ^
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:20: error: package org.apache.http does not exist
[ant:adapterBuilder] import org.apache.http.HttpHost;
[ant:adapterBuilder] ^
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:21: error: package org.apache.http does not exist
[ant:adapterBuilder] import org.apache.http.HttpResponse;
[ant:adapterBuilder] ^
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:22: error: package org.apache.http does not exist
[ant:adapterBuilder] import org.apache.http.HttpStatus;
[ant:adapterBuilder] ^
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:23: error: package org.apache.http.client.methods does not exist
[ant:adapterBuilder] import org.apache.http.client.methods.HttpPost;
[ant:adapterBuilder] ^
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:24: error: package org.apache.http.client.methods does not exist
[ant:adapterBuilder] import org.apache.http.client.methods.HttpUriRequest;
[ant:adapterBuilder] ^
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:25: error: package org.apache.http.entity does not exist
[ant:adapterBuilder] import org.apache.http.entity.StringEntity;
[ant:adapterBuilder] ^
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:26: error: package org.apache.http.impl.client does not exist
[ant:adapterBuilder] import org.apache.http.impl.client.CloseableHttpClient;
[ant:adapterBuilder] ^
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:27: error: package org.apache.http.impl.client does not exist
[ant:adapterBuilder] import org.apache.http.impl.client.HttpClients;
[ant:adapterBuilder] ^
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:28: error: package org.apache.http.util does not exist
[ant:adapterBuilder] import org.apache.http.util.EntityUtils;
[ant:adapterBuilder] ^
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:39: error: cannot find symbol
[ant:adapterBuilder] @Path("/")
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: class Path
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:44: error: cannot find symbol
[ant:adapterBuilder] private static CloseableHttpClient client;
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: class CloseableHttpClient
[ant:adapterBuilder] location: class LoyaltyUserAdapterResource
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:45: error: cannot find symbol
[ant:adapterBuilder] private static HttpHost host;
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: class HttpHost
[ant:adapterBuilder] location: class LoyaltyUserAdapterResource
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:135: error: cannot find symbol
[ant:adapterBuilder] private HttpPost getHttpPost() throws UnsupportedEncodingException {
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: class HttpPost
[ant:adapterBuilder] location: class LoyaltyUserAdapterResource
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:163: error: cannot find symbol
[ant:adapterBuilder] private String execute(HttpUriRequest req) throws Exception {
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: class HttpUriRequest
[ant:adapterBuilder] location: class LoyaltyUserAdapterResource
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/utils/JsonReader.java:19: error: package com.google.gson does not exist
[ant:adapterBuilder] import com.google.gson.JsonParser;
[ant:adapterBuilder] ^
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:68: error: cannot find symbol
[ant:adapterBuilder] public ServerResponse<String> getUserData(@PathParam("phone_number") String phoneNumber,
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: class PathParam
[ant:adapterBuilder] location: class LoyaltyUserAdapterResource
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:69: error: cannot find symbol
[ant:adapterBuilder] @PathParam("locale") String locale){
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: class PathParam
[ant:adapterBuilder] location: class LoyaltyUserAdapterResource
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:65: error: cannot find symbol
[ant:adapterBuilder] @GET
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: class GET
[ant:adapterBuilder] location: class LoyaltyUserAdapterResource
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:66: error: cannot find symbol
[ant:adapterBuilder] @Path("/user-data/{phone_number}/{locale}")
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: class Path
[ant:adapterBuilder] location: class LoyaltyUserAdapterResource
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:67: error: cannot find symbol
[ant:adapterBuilder] @Produces(MediaType.APPLICATION_JSON)
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: class Produces
[ant:adapterBuilder] location: class LoyaltyUserAdapterResource
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:105: error: cannot find symbol
[ant:adapterBuilder] @GET
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: class GET
[ant:adapterBuilder] location: class LoyaltyUserAdapterResource
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:106: error: cannot find symbol
[ant:adapterBuilder] @Path("/watson-data")
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: class Path
[ant:adapterBuilder] location: class LoyaltyUserAdapterResource
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:107: error: cannot find symbol
[ant:adapterBuilder] @Produces(MediaType.APPLICATION_JSON)
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: class Produces
[ant:adapterBuilder] location: class LoyaltyUserAdapterResource
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterApplication.java:17: error: method does not override or implement a method from a supertype
[ant:adapterBuilder] @Override
[ant:adapterBuilder] ^
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterApplication.java:22: error: method does not override or implement a method from a supertype
[ant:adapterBuilder] @Override
[ant:adapterBuilder] ^
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterApplication.java:31: error: cannot find symbol
[ant:adapterBuilder] return getClass().getPackage().getName();
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: method getClass()
[ant:adapterBuilder] location: class LoyaltyUserAdapterApplication
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterApplication.java:27: error: method does not override or implement a method from a supertype
[ant:adapterBuilder] @Override
[ant:adapterBuilder] ^
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:114: error: cannot find symbol
[ant:adapterBuilder] HttpPost httpPost = getHttpPost();
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: class HttpPost
[ant:adapterBuilder] location: class LoyaltyUserAdapterResource
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:137: error: cannot find symbol
[ant:adapterBuilder] HttpPost httpPost = new HttpPost(watsonPath);
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: class HttpPost
[ant:adapterBuilder] location: class LoyaltyUserAdapterResource
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:137: error: cannot find symbol
[ant:adapterBuilder] HttpPost httpPost = new HttpPost(watsonPath);
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: class HttpPost
[ant:adapterBuilder] location: class LoyaltyUserAdapterResource
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:140: error: cannot find symbol
[ant:adapterBuilder] httpPost.setEntity(new StringEntity(watsonString));
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: class StringEntity
[ant:adapterBuilder] location: class LoyaltyUserAdapterResource
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:144: error: cannot find symbol
[ant:adapterBuilder] httpPost.setHeader("Accept", MediaType.APPLICATION_JSON);
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: variable MediaType
[ant:adapterBuilder] location: class LoyaltyUserAdapterResource
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:149: error: cannot find symbol
[ant:adapterBuilder] String encoding = Base64.encodeBase64String(creds.getBytes("UTF-8"));
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: variable Base64
[ant:adapterBuilder] location: class LoyaltyUserAdapterResource
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:164: error: cannot find symbol
[ant:adapterBuilder] client = HttpClients.createDefault();
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: variable HttpClients
[ant:adapterBuilder] location: class LoyaltyUserAdapterResource
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:166: error: cannot find symbol
[ant:adapterBuilder] host = new HttpHost(watsonHost, 443, "https");
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: class HttpHost
[ant:adapterBuilder] location: class LoyaltyUserAdapterResource
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:168: error: cannot find symbol
[ant:adapterBuilder] HttpResponse JSONResponse = client.execute(host, req);
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: class HttpResponse
[ant:adapterBuilder] location: class LoyaltyUserAdapterResource
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:169: error: cannot find symbol
[ant:adapterBuilder] String message = EntityUtils.toString(JSONResponse.getEntity());
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: variable EntityUtils
[ant:adapterBuilder] location: class LoyaltyUserAdapterResource
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/LoyaltyUserAdapterResource.java:171: error: cannot find symbol
[ant:adapterBuilder] if (JSONResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: variable HttpStatus
[ant:adapterBuilder] location: class LoyaltyUserAdapterResource
[ant:adapterBuilder] /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/AdapterBuilderTask1333430620761865396/src/com/ibm/mil/utils/JsonReader.java:81: error: cannot find symbol
[ant:adapterBuilder] contents = new JsonParser().parse(reader).toString();
[ant:adapterBuilder] ^
[ant:adapterBuilder] symbol: class JsonParser
[ant:adapterBuilder] location: class JsonReader
[ant:adapterBuilder] 47 errors
:buildMFPArtifacts FAILED
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/olivieri/Development/eclipse-luna-workspaces/workspace-mil-common-assets/MIL_Common_Assets/gradle_assets/build-deploy-assets/build-mfp.gradle' line: 117
* What went wrong:
Execution failed for task ':buildMFPArtifacts'.
> Build of the adapter 'LoyaltyUserAdapter' failed. The failure message is: 'Compile failed; see the compiler error output for details.'. The failure may have been caused due to incorrect Java code, incompatible JDK level, JAVA_HOME not pointing to the location of a valid JDK or missing dependencies. Note that the worklight-jee-library.jar must be in the classpath when building Java adapters.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.726 secs
$
You are correct that the JEE library is missing. Could it be that you did not declare it in the Ant task?
See this user documentation topic: Building applications and adapters > Building an adapter
building a Java adapter without libs
Building a Java adapter with the server/lib and the adapter/lib folders in the class path