worklight应用程序中心上传文件失败

时间:2013-04-10 18:19:32

标签: ibm-mobilefirst

将应用程序上传到Worklight Application Center时,我在message.log中收到以下错误:

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

此外,在trace.log中,整个堆栈跟踪如下:

[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"}]

有谁能告诉我如何解决这个问题? 顺便说一句,我成功地尝试在worklight控制台中部署wlapp和适配器。

我的环境是:

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

我做了进一步的调查:

  1. 在Win7 64位上使用Worklight Server并连接到同一个数据库实例。一切都很好。此外,我浏览了在Linux环境中运行的应用程序中心。 appcenter在Win7上传的应用程序没有问题。

  2. 从两个envs(RHEL 6和Win7)检查trace.log中的pkg值。结果不同。

  3. 在Win7的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"}]}
    

    在RHEL 6的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}
    

1 个答案:

答案 0 :(得分:1)

您尝试将APK上传到Worklight Application Center时发生错误。在此步骤中,APK将被分析。 RHEL跟踪日志表明不仅缺少pkg(null),而且APK大小为null。这可能表明APK是非常错误的。

第一步是验证APK是否正确。为此,只需将其解压缩(APK是一个zip文件),并验证它是否包含AndroidManifest.xml。该文件是二进制文件,pkg值将来自那里。如果它丢失了,这是致命的。

接下来,验证可以通过aapt(位于平台工具中的Android SDK中)分析APK:

aapt dump badging somefile.apk

您似乎尝试上传IBMApplicationCenter.apk,因此在您的具体情况下,它是:

aapt dump badging IBMApplicationCenter.apk

这会输出几行,通常以

之类的行开头
package: name='com.ibm.appcenter' versionCode='1' versionName='1.0'

这是pkg值的来源。如果这不起作用,则Worklight Application Center无法找到pkg,或者Android Manifest无效。

在APK上传机制期间,会发生以下情况:

  • 如果在服务器配置文件中设置了属性android.aapt或android.aapt.dir(对于Liberty的bootstrap.properties,对于Tomcat的catalina.properties或对于WAS的Java VM属性),那么将在该位置和“aapt dump badging”如前所述执行,输出由Worklight Application Center分析。这可以解释为什么你在Win7和RHEL上看到不同的行为,因为你在那里有不同的执行执行。
  • 如果没有设置android.aapt或android.aapt.dir属性,则Worklight应用程序中心不会使用aapt但会尝试解码APK本身。因此,您可以尝试取消设置服务器中的android.aapt属性并重新启动服务器,以检查是否可以解决问题。