1

我正在尝试将 iOS 应用程序上传到 WSO2 EMM Publisher,但它不断抛出 FileNotFoundException

java.io.FileNotFoundException: null\repository\deployment\server\jaggeryapps\publisher\upload\hlZDGMobileKiosk_368_5256.ipa 
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at com.wso2.mobile.mam.manifestUtils.ZipFileReading.readiOSManifestFile(ZipFileReading.java:87)
    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:601)
    at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
    at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:225)
    at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:42)
    at org.jaggeryjs.rhino.publisher.c0._c_anonymous_1(/publisher//mobileupload.jag:70)
    at org.jaggeryjs.rhino.publisher.c0.call(/publisher//mobileupload.jag)
    at org.mozilla.javascript.optimizer.OptRuntime.call0(OptRuntime.java:23)
    at org.jaggeryjs.rhino.publisher.c0._c_script_0(/publisher//mobileupload.jag:2)
    at org.jaggeryjs.rhino.publisher.c0.call(/publisher//mobileupload.jag)
    at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
    at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
    at org.jaggeryjs.rhino.publisher.c0.call(/publisher//mobileupload.jag)
    at org.jaggeryjs.rhino.publisher.c0.exec(/publisher//mobileupload.jag)
    at org.jaggeryjs.scriptengine.engine.RhinoEngine.execScript(RhinoEngine.java:567)
    at org.jaggeryjs.scriptengine.engine.RhinoEngine.exec(RhinoEngine.java:273)
    at org.jaggeryjs.jaggery.core.manager.WebAppManager.execute(WebAppManager.java:447)
    at org.jaggeryjs.jaggery.core.JaggeryServlet.doPost(JaggeryServlet.java:29)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
    at org.jaggeryjs.jaggery.core.JaggeryFilter.doFilter(JaggeryFilter.java:21)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.wso2.carbon.tomcat.ext.valves.CompositeValve.continueInvocation(CompositeValve.java:178)
    at org.wso2.carbon.tomcat.ext.valves.CarbonTomcatValve$1.invoke(CarbonTomcatValve.java:47)
    at org.wso2.carbon.webapp.mgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:56)
    at org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer.invokeValves(TomcatValveContainer.java:47)
    at org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:141)
    at org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:156)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
    at org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:52)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1653)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

从 wso2 mobileupload.jag 抛出此异常

var path = process.getEnv("PWD")+"/repository/deployment/server/jaggeryapps"+meta.path;

我打印process.getEnv("PWD"),它总是返回 null。那么我该如何解决这个问题呢?

整个 mobileupload.jag 如下:

<%
(function(){
var mam_config = require('/config/mam-config.json');
var log=new Log();
var makeid= function()
{
    var text = "";
    var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

    for( var i=0; i < 5; i++ )
        text += possible.charAt(Math.floor(Math.random() * possible.length));

    return text;
}
var getExtension = function(file){
    var path = file.getName();
    var index = path.lastIndexOf('.');
    var ext = index < path.length ? path.substring(index + 1) : '';
    return ext;
}
var getFileOnly = function(file){
    var path = file.getName();
    var index = path.lastIndexOf('.');
    var name = index < path.length ? path.substring(0,index) : '';
    return name;
}
var saveFile = function(file){
    if(file!=undefined){
        var file_n= file.getName()
        if(file_n==""){
            return "";
        }
        var uid= makeid();
        var file_name = mam_config.filePreciseLocation+uid+file_n;
        file.saveAs(file_name);
        return file_name;
    }
    return "";
}
function mergeRecursive(obj1, obj2) {
    for (var p in obj2) {
        try {
            // Property in destination object set; update its value.
            if (obj2[p].constructor == Object) {
                obj1[p] = MergeRecursive(obj1[p], obj2[p]);
            } else {
                obj1[p] = obj2[p];
            }
        } catch (e) {
            // Property in destination object not set; create it and set its value.
            obj1[p] = obj2[p];
        }
    }
    return obj1;
}
var file = request.getAllFiles().file;
var meta = {};
if(file==undefined){
    //return error
    response.sendError(500);
}else{
    meta.path = saveFile(file);
    meta.path = '/publisher' +meta.path;
    var ext = getExtension(file);
    if(ext=="ipa" || ext =="apk"){
        var zipFileReading = new Packages.com.wso2.mobile.mam.manifestUtils.ZipFileReading();
        var path = process.getEnv("PWD")+"/repository/deployment/server/jaggeryapps"+meta.path;
        try{
            if(ext=="ipa"){
                var d = zipFileReading.readiOSManifestFile(path, getFileOnly(file));
                log.debug(d);
                var information = JSON.parse(d);
                mergeRecursive(meta,information);
            }else if(ext=="apk"){
                var d = zipFileReading.readAndroidManifestFile(path);
                log.debug(d);
                var information = JSON.parse(d);
                mergeRecursive(meta,information);
            }
            print(meta);
            log.debug("Successfully discovered");
        }catch(e){
            log.debug("Uploaded file is corrupted");
            print({"ok" : false, "message" : "Validation failure", "report" : {"failed" : true, "name" : ["Uploaded file is corrupted"]}})
        }
    }else{
        print({"ok" : false, "message" : "Validation failure", "report" : {"failed" : true, "name" : ["Invalid Filetype - Uploaded file is not an archive"]}})
        return;
    }   
}
}());
%>

提前致谢!

4

2 回答 2

1

我通过变通解决方案解决了这个问题,我添加了一个名为“PWD”的系统环境变量,其值设置为“C:/wso2/wso2mobileserver-1.0.0”(MOBILE_SERVER_HOME_DIRECTORY)。

于 2014-05-08T08:53:05.517 回答
1

请更换

process.getEnv("PWD")

Packages.java.lang.System.getProperty("carbon.home") 

在 mobileupload.jag 中

此问题已在 WSO2 Mobile EMM 的 1.1.0 版本中修复

于 2014-06-10T05:44:08.187 回答