2010-03-18 66 views
1

成功構建我的應用程序後,啓動失敗,因爲它依賴位於META-INF目錄中的配置文件,構建之後此目錄被壓縮到jar文件中,因此無法啓動訪問配置文件。手動解壓縮jar文件後,刪除jar文件並用xxx.jar重命名該目錄,程序運行時沒有問題。 SSO登錄(Kerberos)需要配置文件。 下面是代碼:構建Eclipse RCP應用程序,運行失敗

Bundle bundle = Platform.getBundle(Application.PLUGIN_ID); 
String path; 
try { 
    path = new URL(bundle.getLocation().substring(18)).getPath(); 
} catch (MalformedURLException e1) { 
    System.out.println(e1); 
    path=""; 
} 
System.setProperty("java.security.auth.login.config",path+"META-INF/jaas-win.config"); 

Path變量中包含類似「插件/ mydomain.pluginame-xxxx.jar /」 但似乎系統需要解壓的罐子。

這是我做錯了建設的應用程序? 感謝

回答

0

代碼改變後:

ClassLoader cl = Thread.currentThread().getContextClassLoader(); 
    URL authconf = null; 
    authconf= cl.getResource("META-INF/jaas-win.config"); 

    if (authconf == null) { 
     loginContext = null; 
     return; 
    } 

    String p; 
    try { 
     p = URLDecoder.decode(authconf.toExternalForm(), "UTF-8"); 
     System.setProperty("java.security.auth.login.config", p); 
    } catch (UnsupportedEncodingException e1) { 
     loginContext = null; 
     return; 
    } 

現在的工作。

相關問題