Kevin Lin
Kevin Lin

Reputation: 37

worklight application center upload file failed

I got the following error in message.log when uploading an app to Worklight Application Center:

"com.ibm.puremeap.resources.desktop.UploadService W JSON error when trying to upload file IBMApplicationCenter.apk"

Also, in trace.log, the whole stack trace was as below:

[4/10/13 20:23:23:350 CST] 00000148 id=         com.ibm.puremeap.resources.desktop.UploadService             W JSON error when trying to upload file IBMApplicationCenter.apk
[4/10/13 20:23:23:351 CST] 00000148 id=         UploadService                                                2 response THROW
org.apache.wink.json4j.JSONException: The value for key: [pkg] was null.  Object required.
    at org.apache.wink.json4j.JSONObject.getString(JSONObject.java:1098)
    at com.ibm.puremeap.resources.desktop.UploadService.fileUploaded(UploadService.java:198)
    at com.ibm.puremeap.resources.desktop.UploadService.__fileUploadedJSON__(UploadService.java:102)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.apache.wink.server.internal.handlers.InvokeMethodHandler.handleRequest(InvokeMethodHandler.java:63)
    at org.apache.wink.server.handlers.AbstractHandler.handleRequest(AbstractHandler.java:33)
    at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
    at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
    at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:67)
    at org.apache.wink.server.internal.handlers.CreateInvocationParametersHandler.handleRequest(CreateInvocationParametersHandler.java:54)
    at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
    at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
    at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:67)
    at org.apache.wink.server.handlers.AbstractHandler.handleRequest(AbstractHandler.java:34)
    at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
    at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
    at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:67)
    at org.apache.wink.server.internal.handlers.FindResourceMethodHandler.handleSubResourceMethod(FindResourceMethodHandler.java:183)
    at org.apache.wink.server.internal.handlers.FindResourceMethodHandler.handleRequest(FindResourceMethodHandler.java:110)
    at org.apache.wink.server.internal.handlers.FindResourceMethodHandler.handleSubResourceLocator(FindResourceMethodHandler.java:230)
    at org.apache.wink.server.internal.handlers.FindResourceMethodHandler.handleRequest(FindResourceMethodHandler.java:115)
    at org.apache.wink.server.internal.handlers.FindResourceMethodHandler.handleSubResourceLocator(FindResourceMethodHandler.java:230)
    at org.apache.wink.server.internal.handlers.FindResourceMethodHandler.handleRequest(FindResourceMethodHandler.java:115)
    at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
    at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
    at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:67)
    at org.apache.wink.server.internal.handlers.FindRootResourceHandler.handleRequest(FindRootResourceHandler.java:95)
    at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
    at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
    at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:67)
    at org.apache.wink.server.internal.handlers.HeadMethodHandler.handleRequest(HeadMethodHandler.java:53)
    at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
    at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
    at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:67)
    at org.apache.wink.server.internal.handlers.OptionsMethodHandler.handleRequest(OptionsMethodHandler.java:46)
    at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
    at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
    at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:67)
    at org.apache.wink.server.internal.handlers.SearchResultHandler.handleRequest(SearchResultHandler.java:33)
    at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
    at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
    at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:67)
    at org.apache.wink.server.internal.log.ResourceInvocation.handleRequest(ResourceInvocation.java:92)
    at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
    at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
    at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:67)
    at org.apache.wink.server.internal.log.Requests.handleRequest(Requests.java:76)
    at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
    at org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
    at org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:67)
    at org.apache.wink.server.handlers.AbstractHandlersChain.run(AbstractHandlersChain.java:52)
    at org.apache.wink.server.internal.RequestProcessor.handleRequestWithoutFaultBarrier(RequestProcessor.java:207)
    at org.apache.wink.server.internal.RequestProcessor.handleRequest(RequestProcessor.java:154)
    at org.apache.wink.server.internal.servlet.RestServlet.service(RestServlet.java:133)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1234)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:757)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:440)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1041)
    at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:81)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:930)
    at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:274)
    at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:529)
    at com.ibm.ws.threading.internal.Worker.executeWork(Worker.java:398)
    at com.ibm.ws.threading.internal.Worker.run(Worker.java:380)
    at java.lang.Thread.run(Thread.java:636)

[4/10/13 20:23:23:352 CST] 00000148 id=         UploadService                                                2 response Result: {0} 
                                                                                                               [{"message":"The value for key: [pkg] was null.  Object required.","status":200,"exception":"org.apache.wink.json4j.JSONException","acl_upload_denied":"IBMApplicationCenter.apk"}]

Could anyone tell me how can I fix the problem? BTW, I successfully tried to deploy wlapp and adapter in worklight console.

My environment is:

- RHEL v6.x 64 bit
- Worklight v5.0.6
- DB2 10.x

Further investigation I did:

  1. Used a Worklight Server on Win7 64 bit and connected to the same database instance. Every thing is just fine. Furthermore, I browsed the application center running on Linux env. The application which uploaded by the appcenter on Win7 is shown without problem.

  2. checked the pkg value in the trace.log from both envs(RHEL 6 and Win7). The results were different.

On Win7's trace.log:

[2013/4/11   10:48:18:944 TST] 00000040 id=         ApplicationService                                           > __create__ ENTRY {0} {1} {2} 
                                                                                                               uri=http://[hostname_win7]:9080/applicationcenter/service/desktop/application/
                                                                                                               securityContext=org.apache.wink.server.internal.contexts.SecurityContextImpl_1700851040
                                                                                                               {"os":"Android","pkg":"com.ibm.appcenter","version":"1","versionName":"1.0","label":"IBM App Center","author":"appcenteradmin","author_display":"appcenteradmin","mandatory":"N","description":"","remote_url":"","is_installer":"Y","is_active":"Y","is_ready_prod":"Y","files":[{"type":"apk","cid":"1","size":1599708,"filename":"IBMApplicationCenter.apk"}]}

On RHEL 6's trace.log:

[4/11/13 11:44:48:694 CST] 00000308 id=         ApplicationService                                           > __create__ ENTRY {0} {1} {2} 
                                                                                                               uri=http://[hostname_RHEL]:10080/applicationcenter/service/desktop/application
                                                                                                               securityContext=org.apache.wink.server.internal.contexts.SecurityContextImpl_1489398078
                                                                                                               {"files":[{"filename":"IBMApplicationCenter.apk","type":"apk","cid":null,"size":null}],"os":"Android","description":"This is application null.","mandatory":"N","pkg":null,"label":null,"version":null}

Upvotes: 0

Views: 1005

Answers (1)

Georg Sander
Georg Sander

Reputation: 736

The error occured while you tried to upload the APK to Worklight Application Center. During this step, the APK gets analyzed. The RHEL trace log indicates that not only the pkg is missing (null) but also that the APK size is null. This could indicate that the APK is considerably wrong.

The first step is to verify whether the APK is correct. In order to do so, simply unzip it (APK is a zip file), and verify that it contains an AndroidManifest.xml. That file is binary and the pkg value will come from there. If it is missing, this is fatal.

Next, verify that the APK can be analyzed by aapt (located in your Android SDK in platform-tools):

aapt dump badging somefile.apk

It seems you tried to upload IBMApplicationCenter.apk, hence in your specific case, it is:

aapt dump badging IBMApplicationCenter.apk

This outputs several lines, usually starting with a line such as

package: name='com.ibm.appcenter' versionCode='1' versionName='1.0'

This is where the pkg value comes from. If this does not work, then Worklight Application Center has no way to find the pkg, or the Android Manifest is invalid.

During the APK upload mechanism, this is what happens:

  • If the property android.aapt or android.aapt.dir are set in the server configuration files (either bootstrap.properties for Liberty, catalina.properties for Tomcat, or Java VM properties for WAS), then the aapt is searched at that location, and "aapt dump badging" is executed as mentioned before, and the output is analyzed by Worklight Application Center. This could explain why you see a different behavior on Win7 and RHEL, since you have different aapt executibles there.
  • If none of the properties android.aapt or android.aapt.dir is set, then the Worklight Application Center does not use aapt but tries to decode the APK itself. Hence, you could try to unset the android.aapt properties in the server and restart the server, to check whether this solves the problem.

Upvotes: 1

Related Questions